Nagios server is giving wrong output

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Nagios server is giving wrong output

Postby grayloglearn » Thu Jul 06, 2017 9:03 am

HI team,

I want to monitor the tomcat heap memory for this i have created small script, while i am executing the script i am able to get the right output from remote server. The same script i am calling the check_nrpe i am not able to get the wrong out put for ex: if remote server out put is Critical , the nagios server output OK like this i am getting the wrong output.

The below is my script

#!/bin/bash
process=`ps -ef | grep java | grep -v grep | cut -f6 -d ' '| head -n 1`
max=`jmap -heap $process | grep MaxHeapSize | awk '{printf $4}' | tr -s "." " " | awk '{print $1}' | tr -s "(" " " | awk '{print $1}'`
if [ $max -gt 2000 ] ; then

echo "CRITICAL: $max"
exit 2
else
echo "OK: $max"
exit 0
fi
---------------------------------------------------------------------

I have given the in sudo file as
Defaults:nagios !requiretty
Defaults:nrpe !requiretty
nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/check_heap (I saved the script in check_heap)
grayloglearn
 
Posts: 4
Joined: Thu Jul 06, 2017 8:55 am

Re: Nagios server is giving wrong output

Postby tmcdonald » Thu Jul 06, 2017 9:08 am

Can you show us your actual service definition? It sounds like you might not be running it through check_nrpe.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tmcdonald
Support Lead / Operations Engineer
 
Posts: 8726
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios server is giving wrong output

Postby grayloglearn » Fri Jul 07, 2017 2:50 am

Hi ,

Thanks for the reply

i have followed below steps in remote server nrpe.cfg as
command[check_heap]=/usr/local/nagios/libexec/check_heap

i have followed below steps in Nagios server as


define service{
use local-service ; Name of service template to use
host_name Testing
service_description Heap-Memory
check_command check_nrpe!check_heap
register 1
}


I followed below command to execute .
/usr/local/nagios/libexec/check_nrpe -H 192.168.0.5 -c check_heap
OK:

Instead of OK i should get CRITICAL the same script working at remote server perfectly.
grayloglearn
 
Posts: 4
Joined: Thu Jul 06, 2017 8:55 am

Re: Nagios server is giving wrong output

Postby scottwilkerson » Fri Jul 07, 2017 11:46 am

you may need to add the following to your nrpe config
Code: Select all
command[check_heap]=sudo /usr/local/nagios/libexec/check_heap


Additionally, nrpe runs the script under a restricted environment so you may need to alter your script to put the full path to jmap in this line
Code: Select all
max=`jmap -heap $process | grep MaxHeapSize | awk '{printf $4}' | tr -s "." " " | awk '{print $1}' | tr -s "(" " " | awk '{print $1}'`


Finally depending on how you installed NRPE, the nagios user may not be running the check, the nrpe user may be (if there is one).
User avatar
scottwilkerson
CTO
 
Posts: 7911
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Nagios server is giving wrong output

Postby grayloglearn » Mon Jul 10, 2017 4:49 am

Hi ,

Issue got resolved by adding the two below steps.

command[check_heap]= sudo /usr/local/nagios/libexec/check_heap

max=`/opt/jdk1.7.0_79/bin/jmap -heap $process | grep MaxHeapSize | awk '{printf $4}' | tr -s "." " " | awk '{print $1}' | tr -s "(" " " | awk '{print $1}'`

Thanks scottwilkerson
grayloglearn
 
Posts: 4
Joined: Thu Jul 06, 2017 8:55 am

Re: Nagios server is giving wrong output

Postby tmcdonald » Mon Jul 10, 2017 9:34 am

Did you have any further (related) questions or are we okay to close this thread?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tmcdonald
Support Lead / Operations Engineer
 
Posts: 8726
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios server is giving wrong output

Postby grayloglearn » Tue Jul 11, 2017 6:36 am

yes please
grayloglearn
 
Posts: 4
Joined: Thu Jul 06, 2017 8:55 am


Return to Nagios Core

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], NagioShez, Rapsy and 36 guests