Quote:
Originally Posted by sarathveera
#!/bin/bash
USAGE="`basename $0` [-w|--warning]<percent free> [-c|--critical]<percent free>"
THRESHOLD_USAGE="CRITICAL threshold must be greater than WARNING: `basename $0` $*"
percent_free=/tmp/mempercent
critical=""
warning=""
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
# print usage
if [[ $# -lt 4 ]]
then
echo ""
echo "Wrong Syntax: `basename $0` $*"
echo ""
echo "Usage: $USAGE"
echo ""
exit 0
fi
# read input
while [[ $# -gt 0 ]]
do
case "$1" in
-w|--warning)
shift
warning=$1
;;
-c|--critical)
shift
critical=$1
;;
esac
shift
done
# verify input
if [[ $warning -eq $critical || $warning -gt $critical ]]
then
echo ""
echo "$THRESHOLD_USAGE"
echo ""
echo "Usage: $USAGE"
echo ""
exit 0
fi
percent=`lsof -c java|wc -l {'print $1'}`
if [[ "$percent" -gt $critical ]]
then
echo "CRITICAL - ($percent)no. of open files used by java"
exit 2
fi
if [[ "$percent" -gt $warning ]]
then
echo "WARNING - ($percent)no. of open files used by java"
exit 1
fi
if [[ "$percent" -le $warning ]]
then
echo "OK - ($percent)no. of open files used by java"
exit 0
fi
i wrote the above script and gave all permitions to it
i placed it in the
/usr/local/nagios/libexec
and gave command
./check_fd -w 600 -c 700
i got out put
ok- 594 no. of openfiles used by java .
here the result is correct
so then i went to the root there i gave
#/usr/local/nagios/libexec/check_nrpe -H localhost -c check_fd
i got
0k- 5 no. of openfiles used by java
if i change the warning value and critical vale the message is not changing with this command
#/usr/local/nagios/libexec/check_nrpe -H localhost -c check_fd
but if go to the libexec folder the i gave
the ./check_fd -w 500 -c 600
i got
warning - 593 no. of openfiles used by java
this the problem.
|
it works for me.....
Code:
./check_nrpe -H localhost -c check_fd -a 500 600
are you using the -a flag on any of your tests??? if not, look up what it means, and then try it.
Code:
[root@xxxx libexec]# ./check_nrpe -n -H localhost -c check_java -a 300 500
OK - (13)no. of open files used by java
and
Code:
[nagios@ libexec]$ ./check_nrpe -n -H localhost -c check_java -a 300 500
OK - (13)no. of open files used by java
what you are prob missing
Code:
[root@ libexec]# whoami;lsof -c java | awk '{print $1}' | wc -l
root
585
Code:
[nagios@ libexec]$ whoami;lsof -c java | awk '{print $1}' | wc -l
nagios
13
..
Code:
[nagios@ libexec]$ whoami;lsof -c java
nagios
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 16030 root cwd unknown /proc/16030/cwd (readlink: Permission denied)
java 16030 root rtd unknown /proc/16030/root (readlink: Permission denied)
java 16030 root txt unknown /proc/16030/exe (readlink: Permission denied)
java 16030 root NOFD /proc/16030/fd (opendir: Permission denied)
java 16106 root cwd unknown /proc/16106/cwd (readlink: Permission denied)
java 16106 root rtd unknown /proc/16106/root (readlink: Permission denied)
java 16106 root txt unknown /proc/16106/exe (readlink: Permission denied)
java 16106 root NOFD /proc/16106/fd (opendir: Permission denied)
java 16157 root cwd unknown /proc/16157/cwd (readlink: Permission denied)
java 16157 root rtd unknown /proc/16157/root (readlink: Permission denied)
java 16157 root txt unknown /proc/16157/exe (readlink: Permission denied)
java 16157 root NOFD /proc/16157/fd (opendir: Permission denied)
[nagios@ libexec]$
You need to give nagios user sudo access to run the lsof command properly.
type visudo for examples