Hi all,
I have an interesting puzzle for your perusal - if it works, it can easily go in the Zabbix cookbook.
Summary
I have a calculated item "Consumption" that is doing calculations using its own previous data, that is, the item is calling itself along with other items. If ever a dependency of Consumption becomes unsupported and resupported, Consumption will go unsupported and STAY unsupported. This is because when it tries to access its own previous data (ie, max("Consumption",86400)), Consumption recognizes ITSELF as a dependency that is unsupported... and doesn't do the calculation. Can I force it to ignore itself as a dependency?
Current Situation
I'm using Zabbix as a drop-in replacement for cacti. It's taken a little setting up, but it's much more robust - and our calculations are much more accurate.
One of the tasks I ran up against was to figure out the bandwidth consumption out of a port since a given time. Namely, I want to know how much data is consumed on a monthly basis - not a 30 day basis, a MONTHLY basis. Month-to-date. Week-to-date.
This means I can't just chart delta SNMP on ifHCInOctets and ifHCOutOctets, then sum them up, since there's no easy way to select the sum time range.
I'd settled on charting exact values of ifHCInOctets and ifHCOutOctets, and using that to track absolute consumption. I used one item to chart these values once on the beginning of every month, one item for once on the beginning of every week, then one item for the current consumption. I could then subtract 'beginning of the month' from 'current' and get month-to-date. Success!
...except that every time a router is restarted, the 'current' resets back to zero. Crud!
My current solution, then, is to have an item that charts the SIMPLE CHANGE in ifHCInOctets - which will always be positive except for the FIRST poll after a restart - and continually sum that simple change, ie:
As you can see, "Consumption" actually polls itself, looking for its last maximum. In this way, if ifHCInOctets ever drops to 0 because of a reboot, "Consumption" won't notice - ifHCInOctets.Delta will, and will fail for only 30 seconds, which is not long enough for Consumption to go unsupported.
The Problem
Recently, we had a situation where a router had the wrong SNMP credentials. This is long enough that ifHCInOctets.Delta went unsupported... and caused Consumption to go unsupported.
After the problem was fixed, ifHCInOctets.Delta came back online... but Consumption did not. The reason?
Consumption is 'unsupported' because Consumption is 'unsupported' - namely, "Consumption couldn't 'support' itself, because it depended on itself, and it was already 'unsupported,' so Consumption would quit then and there (without even trying to make the calculation). The exact error message is gone, but it was something along the lines of "Could not find max(86400), item "Consumption" not supported."
The Request
I feel like recursive Consumption is a bit of a janky way to solve my problem, but I haven't found a better solution. One of these three things could help:
1. Is there a way to skip the 'not supported' check, that is, force Consumption to do the math on a 'not supported' item?
2. Is there a way to add conditionals to the formula, that is, "if X is not supported, formula = 1, else formula = max("Consumption") + etc?
3. Is there a better way to get data-by-month? Not 30-day or 7-day data, mind you, but data-by-month (sometimes 31, sometimes 28 days)?
Thanks!
I have an interesting puzzle for your perusal - if it works, it can easily go in the Zabbix cookbook.
Summary
I have a calculated item "Consumption" that is doing calculations using its own previous data, that is, the item is calling itself along with other items. If ever a dependency of Consumption becomes unsupported and resupported, Consumption will go unsupported and STAY unsupported. This is because when it tries to access its own previous data (ie, max("Consumption",86400)), Consumption recognizes ITSELF as a dependency that is unsupported... and doesn't do the calculation. Can I force it to ignore itself as a dependency?
Current Situation
I'm using Zabbix as a drop-in replacement for cacti. It's taken a little setting up, but it's much more robust - and our calculations are much more accurate.
One of the tasks I ran up against was to figure out the bandwidth consumption out of a port since a given time. Namely, I want to know how much data is consumed on a monthly basis - not a 30 day basis, a MONTHLY basis. Month-to-date. Week-to-date.
This means I can't just chart delta SNMP on ifHCInOctets and ifHCOutOctets, then sum them up, since there's no easy way to select the sum time range.
I'd settled on charting exact values of ifHCInOctets and ifHCOutOctets, and using that to track absolute consumption. I used one item to chart these values once on the beginning of every month, one item for once on the beginning of every week, then one item for the current consumption. I could then subtract 'beginning of the month' from 'current' and get month-to-date. Success!
...except that every time a router is restarted, the 'current' resets back to zero. Crud!
My current solution, then, is to have an item that charts the SIMPLE CHANGE in ifHCInOctets - which will always be positive except for the FIRST poll after a restart - and continually sum that simple change, ie:
Code:
Item key: "Consumption"
Formula: max("Consumption",86400) + last("ifHCInOctets.Delta",0)
The Problem
Recently, we had a situation where a router had the wrong SNMP credentials. This is long enough that ifHCInOctets.Delta went unsupported... and caused Consumption to go unsupported.
After the problem was fixed, ifHCInOctets.Delta came back online... but Consumption did not. The reason?
Consumption is 'unsupported' because Consumption is 'unsupported' - namely, "Consumption couldn't 'support' itself, because it depended on itself, and it was already 'unsupported,' so Consumption would quit then and there (without even trying to make the calculation). The exact error message is gone, but it was something along the lines of "Could not find max(86400), item "Consumption" not supported."
The Request
I feel like recursive Consumption is a bit of a janky way to solve my problem, but I haven't found a better solution. One of these three things could help:
1. Is there a way to skip the 'not supported' check, that is, force Consumption to do the math on a 'not supported' item?
2. Is there a way to add conditionals to the formula, that is, "if X is not supported, formula = 1, else formula = max("Consumption") + etc?
3. Is there a better way to get data-by-month? Not 30-day or 7-day data, mind you, but data-by-month (sometimes 31, sometimes 28 days)?
Thanks!
because maybe there are more effective ways to produce some interesting you facts ..

Comment