Hello! I have created two templates for Adaptec adaptors by snmp (by Adaptec Storage Manager (because MaxView doesn't work correctly with old windows versions (less then 2012) and old adaptors) and MaxView StorageManager), because some oids are different.Now i wanna automate adding corresponding template to host by the next way: make template, that will check existing of some services (AdaptecStorageManagerAgent and MaxViewblabla), if service exists, than addind template to host? Is it possible? Exist any examples like this?
Ad Widget
Collapse
add template by trigger. how?
Collapse
X
-
i have returned to this task again. i found this way:Hello! I have created two templates for Adaptec adaptors by snmp (by Adaptec Storage Manager (because MaxView doesn't work correctly with old windows versions (less then 2012) and old adaptors) and MaxView StorageManager), because some oids are different.Now i wanna automate adding corresponding template to host by the next way: make template, that will check existing of some services (AdaptecStorageManagerAgent and MaxViewblabla), if service exists, than addind template to host? Is it possible? Exist any examples like this?
1) create template, that check if host have one of program, needed for monitoring
2) create trigger that must start script on python
And now i have a question about this script. It doesn't work sometimes from first lunch.
Code of script is below:
What am i doing wrong?Code:#!/usr/bin/python from pyzabbix import ZabbixAPI import sys z = ZabbixAPI('http://localhost/zabbix', user='userhere', password='passwordhere') #get host name as parameter (it must be caught up from trigger) host_name=sys.argv[1] #template we add templateadd_name = 'Adaptec RAIDs SNMP_maxview_copy' #template we delete templatedel_name = 'test_raid_software' #get host_id hostinfo = z.host.get(filter={"host": host_name}, output="hostid") host_id=hostinfo[0]["hostid"] #get template id for add templateaddinfo = z.template.get(filter={"host": templateadd_name}, output="templateid") templateadd_id=templateaddinfo[0]["templateid"] #get template id for delete (now we don't need template for checking software) templatedelinfo = z.template.get(filter={"host": templatedel_name}, output="templateid") templatedel_id=templatedelinfo[0]["templateid"] z.host.massadd(hosts={"hostid":host_id},templates={"templateid":templateadd_id},templates_clear={"templateid":templatedel_id})
Comment