Ad Widget

Collapse

API: Searching for a specific trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hertell
    Member
    • Aug 2010
    • 31

    #1

    API: Searching for a specific trigger

    I already posted a bug-request (https://support.zabbix.com/browse/ZBX-3344), but i think i either phrased myself wrong, or then i don't understand the answer.

    I try to explain what i want to do:

    I have a named host that runs multiple instances of an application our customer are using. With this api-script i try to build, i would like to maintain all items and triggers that are associated to the customers.

    The item-key is built based on some basic-customer parameter, eg

    application.warning.foo.customer1
    application.warning.bar.customer1
    application.warning.baz.customer1

    application.warning.foo.customer2
    application.warning.bar.customer2
    application.warning.baz.customer2
    etc.

    So, with the help of this formula, i find the item-id, and i can do changes to eg the item's settings or description.

    I'll show a couple of steps i do to find my trail to each step

    I start by finding the host-id this is the way:
    Code:
      def hostid_from_hostname(search,zabbix)
          search_app={"filter"=>{"host"=>["#{search}"]}}
          host = zabbix.raw_api("host.get",search_app)
          return host[0]['hostid']
      end
    Now when i have the host-id, i'll check if customer-specific app exits, if not, then it will be created
    Code:
      def get_appid(search,hostid,zabbix)
        search_app={
          "filter"=>{"name"=>"#{search}"},
          "hostids"=> ["#{hostid}"],
        }
        apps=zabbix.raw_api("application.get",search_app)
          if (apps.count == 1)
            uid = apps[0]['applicationid']
          else
            temp= zabbix.application.create({'name'=>"#{search}",'hostid'=>"#{hostid}"})
            uid = temp['applicationids']
          end
        return uid
      end
    After this, i check if the item-exists, if not, then it will be created.. As i explained above, i get my item-id based a pre-defined key...

    At this point, i want to get my hands on the trigger that is accociated to this item. The problem is that i can't figure out how i will find the trigger-id that is linked to the item-id..

    So any help in getting this mystery solved would be appreciated! :-)
    Last edited by hertell; 17-01-2011, 17:13.
  • hertell
    Member
    • Aug 2010
    • 31

    #2
    anyone with some ideas?

    Comment

    • hertell
      Member
      • Aug 2010
      • 31

      #3
      Is this really something that can't be done with the api?

      Comment

      • hertell
        Member
        • Aug 2010
        • 31

        #4
        bumpping this message a bit up...

        Comment

        • hertell
          Member
          • Aug 2010
          • 31

          #5
          and here we go again..

          Comment

          Working...