Ad Widget

Collapse

SQL query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gfalardi
    Junior Member
    • Sep 2009
    • 11

    #1

    SQL query

    hi,

    I was wondering if anyone knows how to get the history of a trigger with a MySQL query ?

    For exemple, how to get all triggers which went in 'disaster' during the last month.

    Thanks
  • arli
    Member
    • Jan 2008
    • 71

    #2
    Not sure, if it's the best way, but something like that should give you all the not ok events (because triggers generate events, and events have history). If you need severity, you'll probably have to add this condition from triggers table.
    If you don't need human readable host names, just trim down items, functions and hosts tables from query.

    Code:
    SELECT h.host, t.description
    FROM events e, triggers t, items i, functions f, hosts h 
    WHERE e.objectid=t.triggerid 
    AND e.clock > UNIX_TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL 1 MONTH)) 
    AND e.value>0 
    AND i.itemid=f.itemid
    AND f.triggerid=t.triggerid
    AND h.hostid=i.hostid;
    Hope you know what you're doing

    Comment

    Working...