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)
Nagios server is giving wrong output
Re: Nagios server is giving wrong output
Can you show us your actual service definition? It sounds like you might not be running it through check_nrpe.
Former Nagios employee
-
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Re: Nagios server is giving wrong output
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.
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.
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Nagios server is giving wrong output
you may need to add the following to your nrpe config
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
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).
Code: Select all
command[check_heap]=sudo /usr/local/nagios/libexec/check_heap
Code: Select all
max=`jmap -heap $process | grep MaxHeapSize | awk '{printf $4}' | tr -s "." " " | awk '{print $1}' | tr -s "(" " " | awk '{print $1}'`
-
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Re: Nagios server is giving wrong output
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
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
Re: Nagios server is giving wrong output
Did you have any further (related) questions or are we okay to close this thread?
Former Nagios employee
-
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Re: Nagios server is giving wrong output
yes please