Difference between revisions of "Zabbix sql queries"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 2: Line 2:
 
delete from items where hostid=(select hostid from hosts where host='www.example.com');
 
delete from items where hostid=(select hostid from hosts where host='www.example.com');
 
delete from items where hostid=(select hostid from hosts where host='www.example.com') and itemid!=252623 and itemid!=253055;
 
delete from items where hostid=(select hostid from hosts where host='www.example.com') and itemid!=252623 and itemid!=253055;
 +
```
 +
 +
 +
# Not sure if work
 +
```
 +
SELECT DISTINCT host, f.triggerid, e.acknowledged, priority
 +
FROM triggers t
 +
INNER JOIN functions f ON ( f.triggerid = t.triggerid )
 +
INNER JOIN items i ON ( i.itemid = f.itemid )
 +
INNER JOIN hosts ON ( i.hostid = hosts.hostid )
 +
INNER JOIN events e ON ( e.objectid = t.triggerid )
 +
WHERE (e.eventid / 100000000000000)
 +
IN (0)
 +
AND e.object = 0
 +
AND t.value=1
 +
AND hosts.status = 0
 +
AND i.status = 0
 +
AND t.status = 0
 +
AND e.acknowledged = 0
 +
AND e.clock > (SELECT DISTINCT max(e.clock)
 +
FROM triggers t
 +
INNER JOIN functions f ON ( f.triggerid = t.triggerid )
 +
INNER JOIN items i ON ( i.itemid = f.itemid )
 +
INNER JOIN hosts ON ( i.hostid = hosts.hostid )
 +
INNER JOIN events e ON ( e.objectid = t.triggerid )
 +
WHERE (e.eventid / 100000000000000)
 +
IN (0)
 +
AND e.object = 0
 +
AND t.value=1
 +
AND hosts.status = 0
 +
AND i.status = 0
 +
AND t.status = 0
 +
AND e.acknowledged = 1
 +
)
 +
LIMIT 1;
 
```
 
```

Revision as of 16:34, 1 October 2022

delete from items where hostid=(select hostid from hosts where host='www.example.com');
delete from items where hostid=(select hostid from hosts where host='www.example.com') and itemid!=252623 and itemid!=253055;

Not sure if work

SELECT DISTINCT host, f.triggerid, e.acknowledged, priority 
FROM triggers t 
INNER JOIN functions f ON ( f.triggerid = t.triggerid ) 
INNER JOIN items i ON ( i.itemid = f.itemid ) 
INNER JOIN hosts ON ( i.hostid = hosts.hostid ) 
INNER JOIN events e ON ( e.objectid = t.triggerid ) 
WHERE (e.eventid / 100000000000000) 
IN (0) 
AND e.object = 0 
AND t.value=1 
AND hosts.status = 0 
AND i.status = 0 
AND t.status = 0 
AND e.acknowledged = 0 
AND e.clock > (SELECT DISTINCT max(e.clock) 
FROM triggers t 
INNER JOIN functions f ON ( f.triggerid = t.triggerid ) 
INNER JOIN items i ON ( i.itemid = f.itemid ) 
INNER JOIN hosts ON ( i.hostid = hosts.hostid ) 
INNER JOIN events e ON ( e.objectid = t.triggerid ) 
WHERE (e.eventid / 100000000000000) 
IN (0) 
AND e.object = 0 
AND t.value=1 
AND hosts.status = 0 
AND i.status = 0 
AND t.status = 0 
AND e.acknowledged = 1 
)
LIMIT 1;