Ad Widget

Collapse

Export historical Event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • syepes
    Junior Member
    • Jun 2016
    • 8

    #1

    Export historical Event

    Hello,

    I am looking for a SQL Query (MySQL) that will allow me to export all received events (with host & trigger info) of a specific time frame.

    Has anyone tried this?
    ---
    EVENT.TIMESTAMP - HOSTNAME – IPADDRESS - EVENT.AGE - EVENT.ID - ITEM.NAME - ITEM.VALUE - TRIGGER.NAME - TRIGGER.SEVERITY - TRIGGER.STATUS - TRIGGER.VALUE
    ---

    Update: This is the SQL I am using for the moment:

    Code:
    SELECT e.clock as event_ts_epoch,
           From_unixtime(e.clock, '%Y-%m-%d %H.%i.%s') event_ts,
           e.ns as event_age_ns,
           e.eventid as event_id,
           h.host as host_name,
           ip.ip as host_ip,
           i.name as item_name,
           t.description as trigger_name,
           IFNULL(ELT(FIELD(t.priority,0, 1, 2, 3, 4, 5),'not classified','information','warning','average', 'high','disaster'),'unknown') AS trigger_severity,
           IFNULL(ELT(FIELD(t.value,0, 1),'ok','problem'),'unknown') AS trigger_value,
           IF(e.acknowledged=1,a.message,"N/A") as event_msg
     FROM zabbix.hosts h 
           INNER JOIN zabbix.interface ip ON ( h.hostid = ip.hostid )
           INNER JOIN zabbix.host_inventory inv ON ( h.hostid = inv.hostid )
           INNER JOIN zabbix.items i ON ( i.hostid = h.hostid ) 
           INNER JOIN zabbix.functions f ON ( f.itemid = i.itemid ) 
           INNER JOIN zabbix.triggers t ON ( t.triggerid = f.triggerid ),
           zabbix.events e LEFT JOIN zabbix.alerts a ON ( e.eventid = a.eventid )
     WHERE e.objectid = t.triggerid
          -- AND e.acknowledged = 1 -- acknowledged events
          -- AND e.clock BETWEEN 1463574835 AND 1463575835 -- Time Frame
    ORDER BY e.clock DESC
    LIMIT 100
    Last edited by syepes; 03-06-2016, 13:46.
Working...