check_nrpe 2.0 and simple shell scripting

Frank Thyes thyes at gmx.net
Fri Feb 17 21:16:36 CET 2006


Hi Marc,

+++ Marc Powell [Fri, Feb 17, 2006 at 08:40:48PM CET]:
> 
> Typically mail queues are only readable by root. Have you modified
> permissions on the queue directory, the script or are you using sudo to
> run it successfully as a non-root user? The mailq command typically has
> the required permissions and that's why it's used by check_mailq.

Sorry i forgot to mention. Yes i have tried running the nrpe
daemon as root and also setting the script suid even starting the
daemon directly as root or from inetd.
 
> Are you exiting with the proper output and exit code that nagios
> requires? See the Developer Guidelines at http://nagiosplug.sf.net if
> you haven't already. 

I know the site, the return codes are used as decribed.
 
> As to why your script always exits with code 3, we can't tell you since

My mistake the return code isnt 3 its 0 see the log...

> we didn't write the script and you didn't post enough of it to tell
> anything really useful. If that's not what it should be exiting with,
> then change the script to return the proper exit code.

Query from the monitoring host. Its not the first time that i am
using nrpe, other scripts (perl and shell) works as expected.

./check_nrpe -H 10.0.33.180 -c mail 
CHECK_NRPE: Error receiving data from daemon.

The nrpe.cfg on the client which should be checked contains the following line.
command[mail]=/path/to/script/mail

The script is executable and the daemon is started from inetd. Inetd.conf
calls the deamon as root (testing only). The script runs fine if
executed from the shell.

Debugging enabled shows me:
Feb 17 21:04:14 xxxxx nrpe[5777]: Added
command[mail]=/path/to/script/mail
Feb 17 21:04:14 xxxxx nrpe[5777]: INFO: SSL/TLS initialized. All
network traffic will be encrypted.
Feb 17 21:04:14 xxxxx nrpe[5777]: Handling the connection...
Feb 17 21:04:14 xxxxx nrpe[5777]: Host is asking for command 'mail'
to be run...
Feb 17 21:04:14 xxxxx nrpe[5777]: Running command:
/path/to/script/mail
Feb 17 21:04:15 xxxxx nrpe[5777]: Command completed with return
code 0 and output:       0

The script looks like this one (its not the original script but the
error can be reproduced with it)

#!/bin/bash
# 0=OK, 1=WARNING, 2=CRITICAL, 3=UNKNOWN
ACTIVE=`find /var/spool/postfix/active/ -type f | wc -l`
DEFERRED=`find /var/spool/postfix/active/ -type f | wc -l`
AMOUNT=`expr $ACTIVE + $DEFERRED`

THRESHOLD_WARNING=10000
THRESHOLD_CRITICAL=15000

if [ $AMOUNT -ge 0 ]; then
        if [ $AMOUNT -lt $THRESHOLD_WARNING ]; then
                echo $AMOUNT
                exit 0
        fi
fi
if [ $AMOUNT -gt $THRESHOLD_WARNING ]; then
        if [ $AMOUNT -lt $THRESHOLD_CRITICAL ]; then
                echo $AMOUNT
                exit 1
        fi
fi
if [ $AMOUNT -gt $THRESHOLD_CRITICAL ]; then
        echo $AMOUNT
        exit 2
fi
echo unknown; exit 3

xxxxxx:# ./mail
9986
xxxxxx:# echo $?
0

Regards
Frank
-- 
We belong to here where no one cares 
and no one loves. No light and no air to live in
a place called hate, the city of fear.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list