Ad Widget

Collapse

How to get trigger/item info with API?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jason
    Senior Member
    • Nov 2007
    • 430

    #1

    How to get trigger/item info with API?

    I've got the API via andrew farley's php script working and can pull out basic information. However, I'm struggling to find the info I need on the wiki pages for the API. (My PHP level is very basic)

    In short I need to find which hosts have template XXX applied and then find the status of item YYY within that template over time. Alternatively find the status of a trigger (its actually the event I'm guessing) on a certain date/time to see if it went true at all.

    The reason behind this is that I've a script that monitors backup exec and reports to zabbix and want to be able to put up a screen showing for each server with the backup exec template the days over the past X days on which the backup ran successfully and when there were errors/problems so that can spot any trends etc.
  • Jason
    Senior Member
    • Nov 2007
    • 430

    #2
    Ok, I've now managed to pull out a list of hosts with my backup template.

    I need to get for a specified item in the backup template a list of values (with date/time) for each host...

    I can see items for each host but assume thats just a list of items attached to each host so I can get an itemid for each host for the value I'm interested in?

    Currently I pull out the items for each host and search for the description that matches what I'm looking for although I guess thats not going to be the best way of doing it.

    How do I then get the array of the values?

    Comment

    • Aly
      ZABBIX developer
      • May 2007
      • 1126

      #3
      It's not precise, but may help: http://www.zabbix.com/documentation/...i/objects/host
      Zabbix | ex GUI developer

      Comment

      • Jason
        Senior Member
        • Nov 2007
        • 430

        #4
        Aly, I've been using that documentation, but it's so sparse on information to be nearly unusable. For example there is no information on the arrays returned apart from whether its a string/integer or array and the examples aren't there yet.

        I'm hoping if there is an update of the doc with 1.8.1 that it will help things.

        Comment

        • Aly
          ZABBIX developer
          • May 2007
          • 1126

          #5
          If you are familiar with PHP then you can view path_to_frontend/API/classes/
          open any file, there are some methods.. Some of them have short description, and parameters are mostly self explaining.

          For now there is no way to get item values history, it will be implemented soon.

          For your question, as I understand you should get needed info by such request:
          PHP Code:
          host.get(
          "templateids" => array(...), //ids of templates linked to searched hosts
          "select_items" => 1,  // select items for each host
          "extendoutput" => 1// needed for full hosts, items info

          Hope that helps.
          Zabbix | ex GUI developer

          Comment

          • Jason
            Senior Member
            • Nov 2007
            • 430

            #6
            Aly,

            That makes much more sense and its much easier to see whats going on thanks.

            If I've got this correctly I get the templates to find the ID of the template (I can't seem to get getID to work unfortunately ) and then use get hosts with templateids as I've got from before.

            Do we know when we will be able to get values? Is that in 1.8.1?

            Comment

            • Aly
              ZABBIX developer
              • May 2007
              • 1126

              #7
              To get templateids by template name, U should use template.getObjects(), or template.get with parameter "pattern".

              There is some docs on API(pre1.8.1) http://www.zabbix.com/forum/showthread.php?t=15536
              Zabbix | ex GUI developer

              Comment

              • yaap
                Junior Member
                • Aug 2009
                • 20

                #8
                Take a look at http://zabbix.com/forum/showthread.p...8031#post58031

                Comment

                Working...