After some trial and error I managed to get the check_hwinfo plugin only partially working. And by partially I mean manually.
In my '/usr/lib64/nagios/plugins' directory I have the 'check_nrpe_hwinfo.sh' script with the correct permissions:
[root@localhost plugins]# ls -lah | grep hwinfo
-rwxr-xr-x. 1 root root 419 Dec 8 15:35 check_nrpe_hwinfo.sh
In my 'conf.d' directory I have a 'check-hwinfo.cfg' file with the necessary declarations:
define command{
command_name check_hwinfo
command_line $USER1$/check_nrpe_hwinfo.sh $HOSTNAME$ $HOSTADDRESS$
}
define service{
use generic-service
hostgroup_name 1st-floor-windows-nrpe-hosts,2nd-floor-windows-nrpe-hosts
service_description HW Info
notification_options none
normal_check_interval 240
notification_interval 240
retry_check_interval 2
max_check_attempts 120
check_command check_hwinfo
}
On my windows hosts I have the supplied 'check_hwinfo.wsf' file in 'C:\NSClient++\scripts'. When doing double click, the script runs correctly and displays the info in a popup window. Also, I have modified the 'nsclient-full.ini' file like this:
[/settings/external scripts/scripts]
check_hwinfo=c:\windows\system32\cscript.exe //NoLogo //T:30 scripts\check_hwinfo.wsf
check_hwinfo_csv=c:\windows\system32\cscript.exe //NoLogo //T:30 scripts\check_hwinfo.wsf /sep:csv
When on my Nagios server, in the '/usr/lib64/nagios/plugins/' directory I give this command:
./check_nrpe -H 192.168.10.13 -c check_hwinfo
I get the correct output.
The check is supposed to run automatically. But... In the Nagios WebUI i get this error in the line corresponding to check_hwinfo:
(Return code of 126 is out of bounds - plugin may not be executable)
After some experimentation with Nagios I think this is just a generic error.
So... Any ideas why the check executes and returns properly when run manually but not when run automatically?
UPDATE 1:
The 'check_nrpe_hwinfo.sh' file looks exactly like this:
#!/bin/bash
ARG_HOSTNAME=${NAGIOS_HOSTNAME:-$1}
ARG_HOSTADDRESS=${NAGIOS_HOSTADDRESS:-$2}
PATH=${PATH}:/usr/lib64/nagios/plugins
HWINFO="`check_nrpe -H $ARG_HOSTNAME -c check_hwinfo_csv`"
RESULT=$?
ARG_HOSTNAME_CLEAN=`echo $ARG_HOSTNAME | tr -cd '0-9a-zA-Z._-'`
if [ "$RESULT" == 0 ]; then
echo "\"$ARG_HOSTADDRESS\",$HWINFO" > /var/www/html/hwinfo/$ARG_HOSTNAME_CLEAN
fi
echo "$HWINFO"
exit $RESULT
UPDATE 2:
[root@localhost plugins]# ./check_nrpe -H 192.168.10.13 -c check_hwinfo_csv
"Gigabyte Technology Co., Ltd.","P55A-UD3","","1","Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz","2927 MHz","8192 KB","133 MHz","8192M","Non-ECC","4096M/2048M/2048M/0","932 G / 932 G","WDC WD10EALS-002BA0 ATA Device / WDC WD10EZRX-00A8LB0 ATA Device","Microsoft Windows 7 Ultimate "