Ad Widget

Collapse

add template by trigger. how?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mykolaq
    Member
    • May 2015
    • 69

    #1

    add template by trigger. how?

    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?
  • mykolaq
    Member
    • May 2015
    • 69

    #2
    Originally posted by mykolaq
    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?
    i have returned to this task again. i found this way:
    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:
    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})
    What am i doing wrong?

    Comment

    • mykolaq
      Member
      • May 2015
      • 69

      #3
      Not actual.Maked vs network discovery

      Comment

      Working...