Quick guide to a good probe
The design of this probe handles three states;
State 1, didn't return a value or "False"
State 2, returned 1, everything is fine
State 3, returned not 1, something is wrong.
The nice part of this probe is you can customize the message for state 1 and state 3. I consider this the best method to build a standard probe.
If you are really new to the dude stop now and and read the "Before doing anything guide" in this wiki.
The probe in this case is a battery probe for an APC UPS that lets you know if a battery failed.
In order for a probe to do both, return false or the value make a function call from inside a probe.
Here the function grabs the value or returns false.
The if statement reads oid_column returns false.
Description: Returns false or the value in 188.8.131.52.4.1.3184.108.40.206.220.127.116.11
Code: if(array_size(oid_column("18.104.22.168.4.1.322.214.171.124.2.2.4" ,10 ,29)), oid_raw("126.96.36.199.4.1.3188.8.131.52.184.108.40.206", 10, 29) ,"False")
Notice I am using oid_raw() in the function instead of oid().
APC UPS returns a text string "noBatteryNeedsRelplacing(1)" when the battery is. We need the value "1" for the if statement to work. I used oid_raw since it seems to only return numerical values.
As always with any probe you will need to put the correct OIDs in the function if your OID is different than mine.
Now it is time to create a probe. Same as above, click probes, click plus...
Notice below on the available line I am calling the function "upsbat()<> "False"" to see if there is a value or if it is "False".
The great thing about this function/probe combo is the notification error message.
The notification has both "UPS on battery" if the value is not equal to 1 and "Cant read UPS" if the OID is not available, otherwise the probe is up and the device up.
Available: upsbat()<> "False"
Error: if(upsbat()<>"False", if(upsbat() = 1, "", "Warning: Battery needs replaced"), "Warning cant read Battery")
Note: I didn't put a value to graph. There is no reason to graph the value 1. ALTHOUGH you will have to go manually turn off history if you don't want to see a graph at all (individually (inside the probe on its history tab) on each device that you put the probe on) . The default is to graph and not putting a value there gives you a graph of 0. Also keep in mind that values are not graphed if the Error line of the probe is "true".
Kudos go to gsandul for the function and probe template. It has helped me a whole bunch.