I'm trying to configure Icinga to query the SMART status of the hard drives loaded into a storage array I'm configuring.
The issue I've run into is the response from the array when querying the OID of a drive is text, and not a number.
./check_snmp -H 10.0.10.17 -P 2c -C public -o .1.3.6.1.4.1.24681.1.2.11.1.7.1
SNMP OK - "GOOD" |
I'm used to working with numbers rather than strings when dealing with output of check_snmp. Does anyone know how I can create a critical or warning notification when anything other than the output GOOD
is returned?
You certainly already know that
Nagios
needs a number (0,1,2,3) as a return status code from the command launched.if
$?
for thecheck_snmp
command always returns0
, my advice would be to write your own check addingpipe
andgrep
to thecheck_snmp
command, something like :This will return
0 (OK)
if wordGOOD
is found within the output, otherwise it will return1 (Warning)
.You cannot use the stock
check_snmp
with non-numerical values; you have to either write a wrapper around thecheck_snmp
plugin, or use/write a plugin that checks the string values. That's why there are hundreds of SNMP plugin variants for specific hardware. That OID is for a QNAP NAS, right?Usually, you'll find that someone else has already done the work for you. You can probably use one of these plugins as-is, or fork them:
If you need names instead of numbers (OID) you need to convert those OID into mibs. Download the required mibs for the given purpose (hard drive, interface of a router, services etc...). After you download try using the script with a given name for the purpose. for example if i like to use check_snmp to check the uptime ill do this:
./check_snmp -H iphosts -P 2c -C public -o sysUpTime.0
you can then replace the number OID with the mibs name ... that is all pointYou must write your own script.
In this script, you can use the following options of the check_snmp plugin:
For example, I have to verify the state of 3 hdd on my server, with a specified OID. This OID return the string "Normal" when all is ok and "Critical" when there is a problem, so my command is:
It will return when all is ok:
and when there is a problem:
If you want to have numbers instead strings, you must modify the results your script will send to nagios. In my case, I wanted a text with the normal exit of check_snmp, and the value 1 for Normal state and 0 for Critical value for perfdata. So in my script I did like this:
The exit of your script will be:
With at left of the "|" the text will appear in nagios, ahd at the right the values for perfdata by disk.
nagios define the state of the service depending on the value returned by the function
exit
I had the same problem as soon as I had to set warning or critical as a string, so I just used it with the --invert-search and --ereg option, like this:
try this: