LinuxQuestions.org
Help answer threads with 0 replies.
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-03-2010, 04:08 AM   #1
sarathveera
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Rep: Reputation: 0
nagios plugin working fine but in web it is giving different message


Hi,

i wrote a Plugin for the number of open files for a perticular process

it is working fine when we give in the command in the libexec folder

#./check_fd
is working fine

but when i use the command from the root
#/usr/local/nagios/libexec/check_nrpe -H localhost -c check_fd

it is giving the different message and the status also showing wrong

if faced this type of problem tell me and how u rectified that problem


pls tell me how to rectify this problem

thanks in advance
 
Old 02-03-2010, 05:57 AM   #2
sohail0399
Member
 
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154

Rep: Reputation: 23
please check is your NRP service is running because it is checking through nrp?


if you have nagios user then nagios should have permission to execute the sript.

and also the permissions for that script using other system commands etc.
 
Old 02-03-2010, 06:18 AM   #3
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hello and Welcome to LinuxQuestions,

The most important part of your question/problem is missing, namely, what's the error you get? If you want people to help you it's always very important to provide as much info as possible.

Kind regards,

Eric
 
Old 02-03-2010, 08:07 AM   #4
sarathveera
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Original Poster
Rep: Reputation: 0
#!/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.
 
Old 02-03-2010, 08:26 AM   #5
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Did you run the command as root or as nagios user and the same on both servers? On the Nagios server the commands are per default executed by the nagios user.

Kind regards,

Eric
 
Old 02-03-2010, 10:50 PM   #6
sarathveera
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Original Poster
Rep: Reputation: 0
i run the command as the root and as well as in nagios user there is no change in the out i checked in the nagios server also there also the same out pet is comming .
 
Old 02-04-2010, 03:33 AM   #7
sohail0399
Member
 
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154

Rep: Reputation: 23
whats the output of ?

#/usr/local/nagios/libexec/check_nrpe -H localhost -c check_fd


and check the configuration of nrpe, Verify that the command definition in your NRPE configuration file is correct.
 
Old 02-04-2010, 03:36 AM   #8
sohail0399
Member
 
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154

Rep: Reputation: 23
set the debug=1 in nrpe configuration file, restart the nrpe and see the log.
 
Old 02-04-2010, 05:10 AM   #9
sarathveera
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Original Poster
Rep: Reputation: 0
how to see the log ?
which log file i have to see?
 
Old 02-04-2010, 05:24 AM   #10
sohail0399
Member
 
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154

Rep: Reputation: 23
Log Files:
/var/log/syslog

Set debug to 1 in :
# vim /usr/local/nagios/etc/nrpe.cfg
debug=1

open another terminal and execute:
# tail -f /var/log/syslog

then start querying the server with check_nrpe commands
 
Old 02-04-2010, 05:58 AM   #11
sarathveera
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Original Poster
Rep: Reputation: 0
i check the log nothing is coming in that log


i want a new script for monitoring the number of open files for perticular process
If any one wrote script pls paste that scipt here.
 
Old 02-04-2010, 06:03 AM   #12
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hi,

Here you have one from NagiosExchange.

Kind regards,

Eric
 
Old 02-04-2010, 06:10 AM   #13
sarathveera
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Original Poster
Rep: Reputation: 0
i didn't find the plugin for the number of open files for particular process
there is a plugin for total no of open files in the system i don't want that i want for a particular process
 
Old 02-05-2010, 01:49 AM   #14
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hi,

If your script is working locally then you should be able to get it to work with Nagios too. Looking for another script will not solve any problem you have in communication between your Nagios server and the one you're monitoring.

I'll put your script in my test server and Nagios and see what I get. If I encounter problems I'll try to fix them and post here.

And please ask a mod to delete your 'double post'. You're not doing yourself any favors in double posting the same thing and worse if you do it in the same forum.

Kind regards,

Eric
 
Old 02-05-2010, 02:20 AM   #15
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hello sarathveera,

I just copied your script without changing anything on my Nagios server (since it has Java installed), set permissions to allow execute and owner to nagios:nagios and ran it as is. I got an error with this command:
Code:
lsof -c java|wc -l {'print $1'}
The wc -l command doesn't work that way in my opinion, it just counts. After deleting the {'print $1'} part I ran it again as root and got correct result:
Code:
CRITICAL - (322)no. of open files used by java
Next I configured the command in Nagios and tested it from within Nagios (default uses nagios user). I got the same result in Nagios so it works and you'll have to look more into the communication between your Nagios server and the one you are monitoring.

One tip though: change the output and usage description in your script because they are very confusing. For example if you execute the command without options to trigger the usage it states
Code:
Wrong Syntax: openfiles 

Usage: openfiles [-w|--warning]<percent free> [-c|--critical]<percent free>
but when you put in like 30 for warning and 20 for critical (since you state percent free, warning should be greater than critical because it's the percentage of free) you get an error stating that critical must be greater than warning. Furthermore you are not doing any percentage calculations in that script since it concerns number of open files. So I'd change the 'percent free' to 'open files' or something. And also put some alignment in your script in order to make it easier to read.

Kind regards,

Eric
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
cannot find Nagios web interface (Nagios 3.2.0) and O/S = Fedora 10 gutiojj Linux - Newbie 7 02-04-2010 09:55 AM
Nagios Plugin fullgore *BSD 3 10-22-2008 09: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 06:33 PM
LXer: Nagios and Oreon (Nagios web front end) installation and Configuration LXer Syndicated Linux News 0 07-18-2006 09:33 PM
Web start java not working (java works fine) powadha Debian 5 06-05-2004 01:57 PM


All times are GMT -5. The time now is 09:40 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration