Ad Widget

Collapse

How to get trigger host with API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Druid33
    Junior Member
    • Sep 2014
    • 2

    #1

    How to get trigger host with API

    Hi all,

    when i list triggers in zabbix web interface (Monitoring->Triggers), there is column "host".

    In API documentation is no property like this fro trigger.

    IN zabbix database i dont find any relation between triggers and hosts.

    Is there any way to get this information from API or direct access to zabbix database?
  • angelhc
    Senior Member
    Zabbix Certified Specialist
    • Nov 2009
    • 226

    #2
    Hello,
    As I understand you need all the events , with SQL you can use:

    ##Obtain all the events from groups called "servers" on the last 7 days:

    SELECT DISTINCT h.name, t.description, g.name, t.priority, FROM_UNIXTIME(a.clock) FROM triggers t
    INNER JOIN functions f ON ( f.triggerid = t.triggerid )
    INNER JOIN items i ON ( i.itemid = f.itemid )
    INNER JOIN hosts h ON ( i.hostid = h.hostid )
    INNER JOIN hosts ON ( i.hostid = hosts.hostid )
    INNER JOIN events e ON ( e.objectid = t.triggerid )
    INNER JOIN alerts a ON ( a.eventid = e.eventid )
    INNER JOIN hosts_groups hg ON ( hg.hostid = h.hostid )
    INNER JOIN groups g ON ( hg.groupid = g.groupid )
    WHERE (e.eventid DIV 100000000000000) IN (0) AND (e.object-0)=0
    AND hosts.status =0
    AND i.status =0
    AND g.name like "%servers%"
    AND FROM_UNIXTIME(a.clock) > date_add(now(), INTERVAL -7 DAY)
    order by t.priority;

    Hope this helps.
    Regards.
    Number of hosts 1600,Number of items +90k,Number of triggers +22k, Number of users +100, New values per second +1270

    http://zabbixes.wordpress.com/

    Comment

    • Druid33
      Junior Member
      • Sep 2014
      • 2

      #3
      Thanks angelhc,

      it helps.

      Comment

      Working...