Hello. Help me figure out the problem. I have several hosts with active Zabbix agents, and I created a separate host that, through its item, counts the number of available agents using the following formula: sum(last_foreach(/*/zabbix[host,active_agent,available]?[(tag="availability_checker:1")])) and everything would be great, but when the agent is turned off, it returns the value 2, and my counter immediately loses its meaning. How can I set this up correctly? In general, the key idea is for Zabbix to write to me at a certain time "10 out of 11 agents are available" or something like that. What should be the formula to recalculate the number of hosts with the tag availability_checker:1 ? Thanks P.S. sorry for my English
Ad Widget
Collapse
sum of zabbix active agent availability
Collapse
X
-
I think you are running into the last_foreach function returning the last item for each, regardless of how old it is. So when a host goes down and the item no longer gets new data, then the function still grabs the last value it can.
Since 7.0 you can specify how far back last_foreach is allowed to look. In your case this should du the trick. sum(last_foreach(/*/zabbix[host,active_agent,available]?[(tag="availability_checker:1")], 5m )) (the 5minutes can be whatever, but should be larger than your update interval)-
unfortunately no. in case when zabbix agent is unavailable, it still returns value 2, and it turns out such situation: for example I have 10 hosts with tag availability_checker: 1, and formula returns value 10. Then one of my zabbix agent crashes, and its value becomes 2, and the sum is already 11. and it should be 9
-
-
hmm, I'm not sure why your approach gives odd results, but this is what I use to do something very similar:
Use the 'Count' Aggregate function
count(last_foreach(/*/zabbix[host,active_agent,available]?[(tag="availability_checker:1")], 5m ))
If you want to go fancy you could make it check whether the status is 1, but the absence of a status should be enough.
count(last_foreach(/*/zabbix[host,active_agent,available]?[(tag="availability_checker:1")], 5m ),"eq",1)
Comment
Comment