Nagios Server- Remote Plugin "Incorrect Values"

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Shivaramakrishnan
Posts: 71
Joined: Tue May 15, 2012 10:11 pm

Nagios Server- Remote Plugin "Incorrect Values"

Post by Shivaramakrishnan »

Hello,
I just added a service check on the remote client running nrpe.The service check is written in bash and gives the right output when appropriate values are passed to it,have the necessary servers to access and the required ports open.

Sample Output from the command line on the remote client:
/usr/lib/nagios/plugins/check_arcconf.sh -w 50 -c 70
RAID WARNING, 0 numParityErrors, 0 hwErrors, 68 mediumErrors

nrpe_local.cfg file of the remote client
command[check_arcconf]=/usr/lib/nagios/plugins/check_arcconf.sh -w $ARG1$ -c $ARG2$

But when I try to access the same command from the Nagios server,I am getting Null Values and the Output is different.

Sample Output from the command line on the Nagios Server
/usr/lib/nagios/plugins/check_nrpe -H IP_Address
RAID OK, numParityErrors, hwErrors, mediumErrors

Sample Service check Definition:
define service {
use adaptech-raid-checks
hosts xyz
service_description ADAPTECH Raid Check
check_command check_nrpe_1arg!check_arcconf!50!70
}

I have searched many links but no success yet.Can anyone please let me know what I am missing or what am I doing wrong?
Please let me know as soon as possible.

Thanks in advance!!!!
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by agriffin »

When you run it from the command line for testing, make sure it works when run as the nagios user. Many people seem to forget that Nagios checks do not run with root permissions.

Code: Select all

su nagios -s /bin/bash -c "/usr/lib/nagios/plugins/check_arcconf.sh -w 50 -c 70"
Shivaramakrishnan
Posts: 71
Joined: Tue May 15, 2012 10:11 pm

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by Shivaramakrishnan »

Are you talking to run the command as user "nagios" on the server or on the client?
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by agriffin »

I'm talking about the client in this case, but the same advice applies whenever you're testing plugins, whether it's on the Nagios server or a remote client.
Shivaramakrishnan
Posts: 71
Joined: Tue May 15, 2012 10:11 pm

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by Shivaramakrishnan »

And what needs to be done in order to run the script to show the output as shown when run by root.
Shivaramakrishnan
Posts: 71
Joined: Tue May 15, 2012 10:11 pm

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by Shivaramakrishnan »

Hi Agriffin
As root I am getting
[root@dbs01-ple03 ~]# /usr/lib/nagios/plugins/check_arcconf.sh -w 50 -c 70
RAID WARNING, 0 numParityErrors, 0 hwErrors, 68 mediumErrors
As nagios user I am getting
[root@dbs01-ple03 ~]# su nagios -s /bin/bash -c "/usr/lib/nagios/plugins/check_arcconf.sh -w 50 -c 70"
(standard_in) 1: parse error
/usr/lib/nagios/plugins/check_arcconf.sh: line 56: [: : integer expression expected
/usr/lib/nagios/plugins/check_arcconf.sh: line 60: [: : integer expression expected
RAID OK, numParityErrors, hwErrors, mediumErrors
Can you please suggest a way out to deal with this problem?Thanks in advance,
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by agriffin »

All you have to do is log in as root and run the plugin. I suspected you were already doing that to test it; if that wasn't correct please say otherwise.
Shivaramakrishnan
Posts: 71
Joined: Tue May 15, 2012 10:11 pm

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by Shivaramakrishnan »

On the Nagios Server,I am running the command as root
ngo01.atl2:/etc/nagios3/conf.d# whoami
root
ngo01.atl2:/etc/nagios3/conf.d# /usr/lib/nagios/plugins/check_nrpe -H 10.12.10.146 -c check_arcconf
RAID OK, numParityErrors, hwErrors, mediumErrors
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by agriffin »

Something in your script has insufficient file permissions. I can't get very detailed without seeing the source, but it looks like it's whatever is supposed to set the variables used on lines 56 and 60. You could either try to modify the script to work without root permissions, or you could use sudo to run it with root permissions.
Shivaramakrishnan
Posts: 71
Joined: Tue May 15, 2012 10:11 pm

Re: Nagios Server- Remote Plugin "Incorrect Values"

Post by Shivaramakrishnan »

Here is the script.Help me out.
#!/bin/bash
# set -x
# Description:

# This plugin will check the status of a local
# Adaptec AAC-RAID. It will provide how errors happen
#
# where arcconf lives
RUNARCONF="/usr/StorMan/arcconf"
ARCONFLISTSTATE="$RUNARCONF GETLOGS 1 DEVICE tabular"


# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4

if [ ! -x "$RUNARCONF" ]
then
echo "UNKNOWN: $ARCONFLISTSTATE not found or is not executable by the nagios user"
exitstatus=$STATE_UNKNOWN
exit $exitstatus
fi

PROGNAME=`basename $0`

print_usage() {
echo "Usage: $PROGNAME SOME OPTIONS>"
echo ""
echo "Notes:"
echo "-w: WARNING level for errors"
echo "-c: CRITICAL level for errors"
echo ""
}

print_help() {
print_usage
echo ""
echo "This plugin will check the howmany errors happend on Raid Controller."
echo ""
exit 0
}



check_error_count()
{
if [ "$allerrors" -ge "$critlevel" ]
then
"MESSAGE=RAID CRITICAL, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors"
exitstatus=$STATE_CRITICAL
elif [ "$allerrors" -le "$critlevel" ]
then
MESSAGE="RAID WARNING, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors"
exitstatus=$STATE_WARNING
else
MESSAGE="RAID OK, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors"
exitstatus=$STATE_OK
fi
}

if [ $# -lt 4 ]; then
print_usage
exit $STATE_UNKNOWN
fi

exitstatus=$STATE_UNKNOWN #default

while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
-w)
warnlevel=$2
shift
;;
-c)
critlevel=$2
shift
;;
esac
shift
done

# Check arguments for validity
#if [ $warnlevel -gt $critlevel ] # Do the warn/crit values make sense?
#then
# echo "Warn value $warnlevel is greater than critical value of $critlevel"
# print_usage
# exitstatus=$STATE_UNKNOWN
# exit $exitstatus

if [ -n $library ]
then
TMP=`mktemp -t numerrors.XXXXXX` # Create a tmpfile to store the full test result
HTMP=`mktemp -t hwerrors.XXXXXX` # Create a tmpfile to store the full test result
MTMP=`mktemp -t mediumerrors.XXXXXX` # Create a tmpfile to store the full test result
$ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep numParityErrors| awk '{print $3}' > $TMP
$ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep hwErrors | awk '{print $3}' > $HTMP
$ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep mediumErrors | awk '{print $3}' > $MTMP
numParityErrors=`a=$(cat $TMP) ; echo $a | tr ' ' '+'| bc`
hwErrors=`a=$(cat $HTMP) ; echo $a | tr ' ' '+'| bc`
mediumErrors=`a=$(cat $MTMP) ; echo $a | tr ' ' '+'| bc`
allerrors=`echo "$numParityErrors + $hwErrors + $mediumErrors" | bc`
check_error_count
rm -rf $TMP
rm -rf $HTMP
rm -rf $MTMP
fi

echo $MESSAGE
exit $exitstatus
Locked