NRPE returns different value between localhost and remote?


#1

Hello all,

i have a check (simple plugin i have created named “/usr/lib64/nagios/plugins/check_nrpe_nbr_descripteurs_SOAS” on the remote host named “s-soas-01”) that is done using NRPE :

#!/bin/sh
# set -x
WARNING_VALUE=$1
CRITICAL_VALUE=$2

PID_NUMBER=`ps -edf | grep java | grep weblo | awk '{print $2}'`
NBR_DESCRIPTEURS=`/usr/sbin/lsof -p $PID_NUMBER | wc -l`


# CRITICAL should be > than WARNING value !
if  $CRITICAL_VALUE -lt $WARNING_VALUE ]];
then
        echo "ERREUR de syntaxe : Parametre CRITICAL < parametre WARNING."
        exit 2
fi

if ( /usr/bin/test ${NBR_DESCRIPTEURS} -ge $CRITICAL_VALUE )
then
  printf "NBR_DESCRIPTEURS CRITICAL"
  FINAL_RESULT=2
elif ( /usr/bin/test $NBR_DESCRIPTEURS -ge $WARNING_VALUE )
then
  printf "NBR_DESCRIPTEURS WARNING"
  FINAL_RESULT=1
else
  printf "NBR_DESCRIPTEURS OK"
  FINAL_RESULT=0
fi

printf " - ${NBR_DESCRIPTEURS}|NBR_DESCRIPTEURS=${NBR_DESCRIPTEURS};${WARNING_VALUE};${CRITICAL_VALUE}\n"

exit ${FINAL_RESULT}

and here is the /etc/nagios/nrpe.cfg line in the remote host setup :

command[check_nrpe_nbr_descripteurs_SOAS]=/usr/lib64/nagios/plugins/check_nrpe_nbr_descripteurs_SOAS  900 3000

My problem is that when i run it from my nagios server, i get a result and when i run it from the remote host, i get a different result…

From remote host :

[root@s-soas-01 ~]# /usr/lib64/nagios/plugins/check_nrpe_nbr_descripteurs_SOAS 900 3000
NBR_DESCRIPTEURS WARNING - 957|NBR_DESCRIPTEURS=957;900;3000

From nagios server :

[nagios@supervision libexec]$ ./check_nrpe -H s-soas-01 -c check_nrpe_nbr_descripteurs_SOAS 900 3000
NBR_DESCRIPTEURS OK - 5|NBR_DESCRIPTEURS=5;900;3000

Any idea of what i could have missed, i always get “5” as result on the Nagios server ? (my goal is to graph the number of open process for a specific usage).

thanks for your help.

Florent


#2

i finally found my problem, nagios user wasn’t allowed to run lsof command o nthe remote nrpe host.