Hi.
I've been asked to prepare an HTML Red/green like report for scheduled interventions.
I created a bunch of OnDemand collected zabbix_sender items and thought about using the data already stored in Zabbix for that, problem is,
I'm not being able to get both the OK and NOT triggers.descriptions
(The HostGroup, Hosts, items, triggers were specifically created for that end, the 'i.lastclock >=' part is to guarantee the selected items were refreshed since the OnDemand collection start)
Do I really need to confront against history.clock instead of items.lastclock? That table is way bigger...
Can anyone correct my query ?
I've been asked to prepare an HTML Red/green like report for scheduled interventions.
I created a bunch of OnDemand collected zabbix_sender items and thought about using the data already stored in Zabbix for that, problem is,
I'm not being able to get both the OK and NOT triggers.descriptions
(The HostGroup, Hosts, items, triggers were specifically created for that end, the 'i.lastclock >=' part is to guarantee the selected items were refreshed since the OnDemand collection start)
SELECT DISTINCT t.triggerid,t.status,t.description, i.lastclock,t.value,h.host,h.hostid
FROM triggers t,hosts h,items i,functions f, hosts_groups hg
WHERE f.itemid=i.itemid
AND h.hostid=i.hostid
AND hg.hostid=h.hostid
AND t.triggerid=f.triggerid
AND h.status=0
AND t.status IN ('PROBLEM', 'OK')
AND i.lastclock >= UNIX_TIMESTAMP(NOW() - INTERVAL 9 MINUTE)
AND h.hostid IN (select hostid from hosts_groups where groupid = 21
ORDER BY h.host, i.lastclock DESC
FROM triggers t,hosts h,items i,functions f, hosts_groups hg
WHERE f.itemid=i.itemid
AND h.hostid=i.hostid
AND hg.hostid=h.hostid
AND t.triggerid=f.triggerid
AND h.status=0
AND t.status IN ('PROBLEM', 'OK')
AND i.lastclock >= UNIX_TIMESTAMP(NOW() - INTERVAL 9 MINUTE)
AND h.hostid IN (select hostid from hosts_groups where groupid = 21
ORDER BY h.host, i.lastclock DESC
Can anyone correct my query ?
Comment