Ad Widget

Collapse

Export list of all performance triggers for the last X months

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dryang
    Junior Member
    • Aug 2016
    • 8

    #1

    Export list of all performance triggers for the last X months

    What is the best way to export a list of all performance triggers that happened in the last 3 months?
  • dryang
    Junior Member
    • Aug 2016
    • 8

    #2
    Anybody can help with that? I understand it can't be done through web interface. Should I use API or write custom SQL query?

    Comment

    • dryang
      Junior Member
      • Aug 2016
      • 8

      #3
      I wrote this query which supposedly does what I expect. Maybe it will be useful to someone else:
      Code:
      SELECT
          FROM_UNIXTIME(e.clock) AS timestamp,
          t.description,
          CASE
              WHEN t.priority = 2 THEN 'Warning'
              WHEN t.priority = 3 THEN 'Average'
              WHEN t.priority = 4 THEN 'High'
              WHEN t.priority = 5 THEN 'Disaster'
              ELSE t.priority
          END AS priority,
          h.host,
          IFNULL(q.name, "none") AS app_name
      FROM events e
      INNER JOIN triggers t
          ON e.objectid = t.triggerid
      LEFT JOIN functions f
          ON f.triggerid = t.triggerid
      LEFT JOIN items i
          ON i.itemid = f.itemid
      LEFT JOIN (
          SELECT
              ia.itemid,
      	a.name
          FROM items_applications ia
          LEFT JOIN applications a
      	ON a.applicationid = ia.applicationid
          GROUP BY
      	ia.itemid
      ) q
          ON q.itemid = f.itemid
      LEFT JOIN hosts h
          ON h.hostid = i.hostid
      WHERE
          t.priority > 1
          AND q.name IN ("CPU", "ICMP", "Memory", "Processes")
      ORDER BY
          e.eventid

      Comment

      Working...