Zabbix trigger mathPosted: June 28, 2012
I have a number of more complex or compound triggers in my Zabbix environment. I regularly create trigger expressions using OR ( | ) to test for multiple conditions. It makes me feel better that I can watch for a particular value in a result as well as whether no data has been received by the Zabbix server and alert accordingly.
I recently had a request to monitor the number of results in a log file. If this results number dropped by, say, 10 percent since the last check then the trigger should fire an alert. I wasn’t quite sure how to accomplish this so I visited the Zabbix Triggers page once again. Usually, I reference the functions section but the expression operators section caught my eye this time.
I knew that I was going to have to do some trigger math to solve my problem but I wasn’t even sure that it could be done. I questioned the Mighty Zabbix and should have known better. Mixed in with the well-known OR, AND, less than, and greater than is the ability to use addition, subtraction, multiplication, and division in your trigger expressions. Exactly what I needed.
The trigger ended up being this simple. We all learned this type of arithmetic in grade school.
This trigger basically says, take the current result (last) divided by the last result (prev) and if it is less than .90 (a 10%+ change since the last result) the trigger is true.
This is exactly what I was looking for. I added an OR that checked for no data over the last 10 minutes for additional monitoring and I was all set.
This trigger math will come in handy in the future for sure. I may even look through some of my triggers to see which ones may be improved by different logic.
Give this trigger arithmetic a try when you have a chance. I’m sure you’ll find it as helpful as I did.