Tue May 15, 2012 10:35 pm
This has always been a pain in the dude, dealing with 0. Zero is null which is false even if it is the actual value read from SNMP (this is certainly a "feature"). Also even though the manual will say -1 is false it is not. So available line has to return a non zero value.
Here is a template to use for every probe you ever make...
Use a function to read the OID values and use a probe to verify those values. Every function should have two results, the result you are interested in graphing and the result you get when the OID is not available. Then use that function in a probe. Every probe should return 3 values; true, the error, and down. (Note: true = "")
The following function checks to make sure that the OID that is attempted to be read actually has a value in it even if it is "0" the result will be true. Notice the +1, this should be subtracted out just before graphing and testing the value in the probe.
Function: test
CODE: if(string_size(oid("x.x.x")), oid("x.x.x")+1, "False")
Also note that 0 is much easier to test for than "false" so modifying the above CODE to 0 instead of "False" is recommended.
The following probe verifies that the oid is actually available, then tests the oid vs a value and returns an error if the value is outside the range and then if the device is down it will complain that the oid is unreachable. Finally drop the value in to graph -1. This was based on a CPU probe.
Probe: testoid
AVAILABLE: test() <> "False"
ERROR: if(test()<>"False",if(test() -1< 80, "", concatenate("Warning: high CPU = ", test(), "%")), "Device unreachable")
VALUE: test()-1
UNIT: %
Note: if you used 0 in the function for false use 0 in the probe for false.
Build probes as above and you will be much happier with your work.
Lebowski
[clarity]