Hi!
We're using the API to create some simple dashboards.
We use ruby for the connection (https://github.com/Pragmatic-Source/zabby)
A sample script to get trigger status:
Some queries are every 10 seconds the other in larger intervals (10 or 15 minutes).
The generated queries take some time (at the beginning about 10 seconds) to return results. After a while (about 8 hours to one day) the query hangs forever.
So the list of open queries grows and eventualy zabbix gets no free connection to the DB and stops.
The SQL query looks like
We're using the API to create some simple dashboards.
We use ruby for the connection (https://github.com/Pragmatic-Source/zabby)
A sample script to get trigger status:
Code:
serv = Zabby.init do
set server: ZabbixCredentials::SERVER
set user: ZabbixCredentials::USERNAME
set password: ZabbixCredentials::PASSWORD
login
end
env = serv.run do
Zabby::Trigger.get(
'filter' => { 'priority' => states.keys },
'output' => 'extend',
'only_true' => 'true',
'monitored' => 1,
'selectItems' => 1,
'withUnacknowledgedEvents' => 1,
'skipDependent' => 1,
'expandData' => 'host'
)
end
The generated queries take some time (at the beginning about 10 seconds) to return results. After a while (about 8 hours to one day) the query hangs forever.
So the list of open queries grows and eventualy zabbix gets no free connection to the DB and stops.
The SQL query looks like
Code:
SELECT DISTINCT t.*,h.name AS hostname,h.host,h.hostid FROM triggers t,functions f,items i,hosts h WHERE NOT EXISTS (SELECT NULL FROM functions f,items i,hosts_groups hgg LEFT JOIN rights r ON r.id=hgg.groupid AND r.groupid='13' WHERE t.triggerid=f.triggerid AND f.itemid=i.itemid AND i.hostid=hgg.hostid GROUP BY i.hostid HAVING MAX(permission)<2 OR MIN(permission) IS NULL OR MIN(permission)=0) AND NOT EXISTS (SELECT NULL FROM functions f,items i,hosts h WHERE t.triggerid=f.triggerid AND f.itemid=i.itemid AND i.hostid=h.hostid AND (i.status<>0 OR h.status<>0)) AND t.status=0 AND EXISTS (SELECT NULL FROM events e WHERE t.triggerid=e.objectid AND e.source=0 AND e.object=0 AND e.value=1 AND e.acknowledged=0) AND t.priority IN ('2','3','4','5','99') AND t.flags IN ('0','4') AND ((t.value=1) OR ((t.value=0) AND (t.lastchange>1467180927))) AND f.triggerid=t.triggerid AND f.itemid=i.itemid AND h.hostid=i.hostid
Comment