Еще один полезный SQL запрос для Zabbix
Получение триггеров с учетом зависимостей. Т.е. Если некий тригер А зависит от триггера Б, то его в списке не будет.
1 |
SELECT (UNIX_TIMESTAMP()-triggers.lastchange)/60 as minut,hosts.host, triggers.description, triggers.comments, triggers.triggerid FROM triggers INNER JOIN functions ON triggers.triggerid=functions.triggerid INNER JOIN items ON items.itemid=functions.itemid INNER JOIN hosts ON hosts.hostid=items.hostid INNER JOIN hosts_groups ON hosts_groups.hostid=hosts.hostid INNER JOIN groups ON groups.groupid=hosts_groups.groupid WHERE hosts.status = 0 AND items.status = 0 AND triggers.status = 0 AND triggers.priority=5 AND triggers.value=1 and ((UNIX_TIMESTAMP()-triggers.lastchange)/60)>15 and triggers.triggerid in (select triggerid_up from trigger_depends where triggerid_down in (SELECT triggers.triggerid FROM triggers INNER JOIN functions ON triggers.triggerid=functions.triggerid INNER JOIN items ON items.itemid=functions.itemid INNER JOIN hosts ON hosts.hostid=items.hostid INNER JOIN hosts_groups ON hosts_groups.hostid=hosts.hostid INNER JOIN groups ON groups.groupid=hosts_groups.groupid WHERE hosts.status = 0 AND items.status = 0 AND triggers.status = 0 AND triggers.priority=5 AND triggers.value=1 and ((UNIX_TIMESTAMP()-triggers.lastchange)/60)>15 group by triggerid)) group by triggers.triggerid |