Nagios server is giving wrong output

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

Nagios server is giving wrong output

Post by grayloglearn »

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)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios server is giving wrong output

Post by tmcdonald »

Can you show us your actual service definition? It sounds like you might not be running it through check_nrpe.
Former Nagios employee
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

Re: Nagios server is giving wrong output

Post by grayloglearn »

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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Nagios server is giving wrong output

Post by scottwilkerson »

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).
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

Re: Nagios server is giving wrong output

Post by grayloglearn »

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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios server is giving wrong output

Post by tmcdonald »

Did you have any further (related) questions or are we okay to close this thread?
Former Nagios employee
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

Re: Nagios server is giving wrong output

Post by grayloglearn »

yes please
Locked