Page 1 of 1

Plugin exit code help

Posted: Wed Feb 10, 2016 6:17 pm
by lee.krause
I have created a script to check the number of used inodes on Solaris10/11.

I ran the following as the nagios user...

When I run my script on the client I get:
bash-4.1$ /etc/nagios/nrpe/check_disk_inodes -w 80 -c 90
/oracle/DX1 inodes 3% used
bash-4.1$ echo $?
0
When I run the check NRPE command from the Nagios Server I get:
bash-4.1$ /usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx -t 30 -c check_disk_inodes -a '-w 80 -c 90'
/oracle/DX1 inodes 3% used
bash-4.1$ echo $?
2

Code: Select all

#!/bin/bash

while test -n "$1"; do
    case "$1" in
        -w)
            WarnInodes=$2
            shift
            ;;
        -c)
            CritInodes=$2
            shift
            ;;
        -p)
            Partition=$2
            shift
            ;;
    esac
    shift
done

sid=`sudo df -h |awk '{print $NF}' | grep oracle | egrep -v '(log|arch|data|oracle$)'`

inode=`sudo df -o i $sid | awk '{print $4}' | grep -v iused | sed 's/%//g'`

#echo $inode $WarnInodes $CritInodes

if [ "$inode" -lt "$WarnInodes" ];
        then
        echo "$sid inodes $inode% used"
        exit 0
fi
if [ "$inode" -gt "$WarnInodes" -a "$inode" -lt "$CritInodes" ];
        then
        echo "$sid inodes $inode% used"
        exit 1
fi
if [ "$inode" -gt "$CritInodes" ];
        then
        echo "$sid inodes $inode% used"
        exit 2
fi

Thanks in advance!

Re: Plugin exit code help

Posted: Wed Feb 10, 2016 7:22 pm
by Box293
Can you please post your check_disk_inodes command that is defined in nrpe.cfg.

Re: Plugin exit code help

Posted: Thu Feb 11, 2016 8:11 am
by lee.krause
command[check_disk_inodes]=/etc/nagios/nrpe/check_disk_inodes

Re: Plugin exit code help

Posted: Thu Feb 11, 2016 8:44 am
by lee.krause
OK looks like I misunderstood the relationship of the commands in the nrpe.cfg.
I thought the check_nrpe would add the arguments.
I changed the nrpe.cfg to:
command[check_disk_inodes]=/etc/nagios/nrpe/check_disk_inodes $ARG1$ (being the next field in the GUI after the check_nrpe) and it worked.

Re: Plugin exit code help

Posted: Thu Feb 11, 2016 10:31 am
by hsmith
Is there anything else you need assistance with, or is this topic good to close?

Re: Plugin exit code help

Posted: Thu Feb 11, 2016 12:52 pm
by lee.krause
Sure you can close it.

Re: Plugin exit code help

Posted: Thu Feb 11, 2016 1:12 pm
by bwallace
Glad we were able to help. We'll lock this thread now and feel free to open another should you require assistance with anything else.