LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-10-2010, 10:06 AM   #16
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116

Quote:
Originally Posted by sarathveera View Post
#!/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

Last edited by centosboy; 02-10-2010 at 10:24 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Nagios and Oreon (Nagios web front end) installation and Configuration LXer Syndicated Linux News 1 05-31-2016 07:26 AM
cannot find Nagios web interface (Nagios 3.2.0) and O/S = Fedora 10 gutiojj Linux - Newbie 7 02-04-2010 08:55 AM
Nagios Plugin fullgore *BSD 3 10-22-2008 08:52 AM
LXer: Nagios 2.5 and Oreon 1.3 (Nagios web front end) installation with screenshots LXer Syndicated Linux News 0 08-11-2006 05:33 PM
Web start java not working (java works fine) powadha Debian 5 06-05-2004 12:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration