Aktionen

Zabbix fertige Datenbank abfragen

Aus znilwiki

Version vom 12. Dezember 2017, 15:19 Uhr von BLinz (Diskussion | Beiträge) (→‎Events eines Host)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

Events eines Host

Die Events selbst:

SELECT * FROM events JOIN triggers ON events.objectid = triggers.triggerid JOIN functions ON functions.triggerid = triggers.triggerid JOIN items ON items.itemid = functions.itemid JOIN hosts ON items.hostid = hosts.hostid WHERE events.source = 0  AND  LOWER(hosts.host) like 'lin-eu-dmstst04'  AND events.clock>=unix_timestamp('2017-12-01 00:00:00')  AND events.clock<=unix_timestamp('2018-12-12 16:00:00')  ORDER BY events.clock DESC;

Nur die Anzahl:

SELECT COUNT(*) FROM events JOIN triggers ON events.objectid = triggers.triggerid JOIN functions ON functions.triggerid = triggers.triggerid JOIN items ON items.itemid = functions.itemid JOIN hosts ON items.hostid = hosts.hostid WHERE events.source = 0  AND  LOWER(hosts.host) like 'lin-eu-dmstst04'  AND events.clock>=unix_timestamp('2017-12-01 00:00:00')  AND events.clock<=unix_timestamp('2018-12-12 16:00:00')  ORDER BY events.clock DESC;

Als Bash-Abfrage, ohne Header, nur die nackte Zahl:

mysql -sN -uzabbix -pzabbix zabbix -e "SELECT COUNT(*) FROM events JOIN triggers ON events.objectid = triggers.triggerid JOIN functions ON functions.triggerid = triggers.triggerid JOIN items ON items.itemid = functions.itemid JOIN hosts ON items.hostid = hosts.hostid WHERE events.source = 0  AND  LOWER(hosts.host) like 'lin-eu-dmstst04'  AND events.clock>=unix_timestamp('2017-12-01 00:00:00')  AND events.clock<=unix_timestamp('2018-12-12 16:00:00')  ORDER BY events.clock DESC;"