I'm trying to monitor web services on a large number of servers using zabbix proxies in different cloud datacenters to get stats from multiple geographic locations. For each server, I've created multiple hosts e.g.: zabtest-via-proxy1, zabtest-via-proxy2, zabtest-via-proxy3, etc. and placing the hosts behind zabbix proxies. This is working well in that I'm getting the desired stats, but for the purposes of triggers/alerts, I'm trying to create a virtual host which aggregates stats and only alerts if all the proxies agree the web service is unresponsive. I manually created a virtual host with a calculated value like this:
This works great -- I get a synthesized item which is the count of proxies that see the web service as unresponsive! So far so good, but when I tried to scale this by templating the formula above -- I'm stumped... My thought was to try to use macros like this:
...but neither HOST macros nor user macros seem to work in the key part of functions in formulae. I get errors like this showing the macro isn't expanded:
Reading that macros *do* work in parameters, I tried creating a parameter on each of the hosts like this:
This creates a "down" key as expect:
But when I try to reference the "down" item from the hosts using a calculated value on the virtual host using e.g.
I run into a slightly different error:
One way I could do this would be to create a host group for each of the web servers and use aggregate checks on the group, but... I have upwards of 300 servers to monitor and 300 host groups seems messy...
So, I'm stumped and would appreciate any ideas/experience using macros in templates to enable calculated items on multiple hosts -- or any other scheme to accomplish "host:item aggregation without using host groups".
Code:
Name: failcount
Key: webservice.failcount
Formula:
last("zabtest-via-proxy1:web.test.fail[Webservice]") +
last("zabtest-via-proxy2:web.test.fail[Webservice]") +
last("zabtest-via-proxy3:web.test.fail[Webservice]")
Code:
Name: failcount
Key: webservice.failcount
Formula:
last("{HOST.HOST}-via-proxy1:web.test.fail[Webservice]") +
last("{HOST.HOST}-via-proxy2:web.test.fail[Webservice]") +
last("{HOST.HOST}-via-proxy3:web.test.fail[Webservice]")
Cannot evaluate function "last()": item "zabtest:{$HOSTVIAPROXY1}:web.test.fail[Webservice]" does not exist.
Code:
Name: down
Key: webservice.downcount
Formula:
last("down[{HOST.HOST}-via-proxy1]")
Code:
down[zabtest-via-proxy1]
Code:
last("down[zabtest-via-proxy1]")
Cannot evaluate function "last()": item "zabtest:down[zabtest-via-proxy1]" does not exist.
So, I'm stumped and would appreciate any ideas/experience using macros in templates to enable calculated items on multiple hosts -- or any other scheme to accomplish "host:item aggregation without using host groups".
Comment