Last active
June 12, 2023 12:46
-
-
Save v-zhuravlev/7a216c7e5f42c3747acd98dd426a8f39 to your computer and use it in GitHub Desktop.
Zabbix SQL queries collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select count(*) FROM (select distinct h.hostid, h.host, t.description from triggers t | |
join functions f on f.triggerid = t.triggerid | |
join items i on i.itemid = f.itemid | |
join hosts h on h.hostid = i.hostid | |
join hosts_groups hg on h.hostid = hg.hostid | |
join hstgrp hg2 on hg2.groupid = hg.groupid | |
where | |
-- value=1 - trigger is in problem state | |
t.value = 1 and | |
-- t.status=0 - trigger is enabled | |
t.status = 0 and | |
-- h.status=0 - host is enabled | |
h.status = 0 | |
-- host name filter. Can be changed to hostid instead | |
and h.host = "somehost" | |
-- host group name filter | |
-- and hg2.name = "somegroupname" | |
-- optional severity filter where 0 - not classified, 1 - normal, 2 - warning, 3 - average, 4 - high, 5 - disaster | |
-- and t.priority > 3 | |
-- optional extra filter on trigger description... | |
-- and t.description like '%Trigger name' | |
-- | |
) as subq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select distinct h.hostid, h.host, t.description from triggers t | |
join functions f on f.triggerid = t.triggerid | |
join items i on i.itemid = f.itemid | |
join hosts h on h.hostid = i.hostid | |
join hosts_groups hg on h.hostid = hg.hostid | |
join hstgrp hg2 on hg2.groupid = hg.groupid | |
where | |
-- value=1 - trigger is in problem state | |
t.value = 1 and | |
-- t.status=0 - trigger is enabled | |
t.status = 0 and | |
-- h.status=0 - host is enabled | |
h.status = 0 | |
-- host name filter. Can be changed to hostid instead | |
and h.host = "somehost" | |
-- host group name filter | |
-- and hg2.name = "somegroupname" | |
-- optional severity filter where 0 - not classified, 1 - normal, 2 - warning, 3 - average, 4 - high, 5 - disaster | |
-- and t.priority > 3 | |
-- optional extra filter on trigger description... | |
-- and t.description like '%Trigger name' | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
References:
https://zabbix.org/wiki/Docs/DB_schema/trunk/
https://www.zabbix.com/documentation/5.0/manual/api