2

I'm trying to monitor java memory usage using nagios nrpe features. So I download and install check_jstat and install the plugin on the remote server. And when I ran it below is the result:

OK: jstat process 819 alive|pid=819 heap=344409;3072000;11;-1;-1 perm=156121;1198080;13;-1;-1

When I run it from the nagios server I'm getting :

root@ip-xx-xx-xx-xx:/usr/local/nagios/libexec# ./check_nrpe -H 172.31.5.84 -c check_jstat
NRPE: Unable to read output
root@ip-xx-xx-xx-xx:/usr/local/nagios/libexec# ./check_nrpe -H 172.31.5.84 -c check_jstat -w 80 -c 90
NRPE: Unable to read output

Below is my config:

On the remote server :

command[check_jstat]=sudo /usr/lib/nagios/plugins/check_jstat -p `pgrep java` -w 85 -c 95

On the Nagios Server:

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       JA_Staging
        service_description             Java Mem Usage
        check_command                   check_nrpe!check_jstat!
        notifications_enabled           1;
        }

I'm pretty sure the Nagios is unable to handle the output or doesn't understand the format... Please help.

Diamond
  • 9,001
  • 3
  • 24
  • 38
cam
  • 21
  • 2
  • Please post the command you are using locally that works (for the first output). – Diamond Feb 05 '16 at 13:40
  • Please verify that the `/usr/lib/nagios/plugins/check_jstat` file is executable (using `chmod 755 /usr/lib/nagios/plugins/check_jstat` command) and that you have restarted NRPE and your Nagios server after adding the command. – Oldskool Feb 05 '16 at 15:59
  • Yes it is executable and when i execute it locally it is working fine. The issue is when i try to execute from the Nagios server i'm getting the unable to read output. ./check_nrpe -H 172.31.5.84 -c check_jstat NRPE: Unable to read output... i'm not sure how to put the argument so Nagios can understand it .... sob – cam Feb 06 '16 at 06:21
  • And the local command is ./check_jstat -p `ps -ef|pgrepjava`. user@ip-XX-XX-XX-XX:/usr/lib/nagios/plugins$ ./check_jstat -p `ps -ef|pgrep java` OK: jstat process 819 alive|pid=819 heap=416422;3072000;13;-1;-1 perm=156123;1198080;13;-1;-1 – cam Feb 06 '16 at 06:30
  • even this works too locally ./check_jstat -p `pgrep java` – cam Feb 06 '16 at 06:32
  • Wild guess, sudo's `requiretty` - add to your sudoers: `Defaults:username !requiretty` – lazyfrosch Feb 08 '16 at 06:33
  • Check the user from which you are running the java process in the remote server. For example if your java process is running from **example** user, then check_jstat plugin won't be able to provide you statistics of the process unless you run the command from **example** user. – Gaurav Pundir Feb 08 '16 at 09:38
  • on the local where java is running i enable nagios to run using one particular user as below on /etc/sudoers :::: Defaults:nagios !requiretty nagios ALL=(someuser) NOPASSWD: /usr/lib/nagios/plugins/check_jstat nagios ALL=(someuser) NOPASSWD: /usr/bin/jstat nagios ALL=(someuser) NOPASSWD: /opt/jdk1.8/bin/jstat and on the Nagios Server i have the setting on /etc/sudoers as ::::::Defaults:nagios !requiretty nagios ALL=(someuser) NOPASSWD:/usr/local/nagios/libexec/check_nrpe!check_jstat! – cam Feb 08 '16 at 09:52
  • @Gaurav Pundir Ran the command inside /usr/local/nagios/libexec# ./check_nrpe -H 172.31.5.84 -c check_jstat NRPE: Unable to read output . It is still the same issue .... – cam Feb 08 '16 at 11:30
  • on remote server change your config ... command[check_jstat]=sudo /usr/lib/nagios/plugins/check_jstat -p `pgrep java` -w 85 -c 95 to command[check_jstat]=sudo su - $JAVA_USER -c "/usr/lib/nagios/plugins/check_jstat -p `pgrep java` -w 85 -c 95" – Gaurav Pundir Feb 08 '16 at 11:50
  • @Gaurav Pundir on the remote server where java is running made the change as command[check_jstat]=sudo su -$jbilling -c "/usr/lib/nagios/plugins/check_jstat -p `pgrep java` -w 85 -c 95" and /etc/init.d/nagios-nrpe-server restart. And on the Nagios Server service nagios restart and try it again ./check_nrpe -H 172.31.5.84 -c check_jstat NRPE: Unable to read output still the same issue... – cam Feb 08 '16 at 13:11
  • @Gaurav Pundir Nagios server end config: define service{ use generic-service ; Name of service template to use host_name Java_Server service_description Java Mem Usage check_command check_nrpe!check_jstat!85!95! notifications_enabled 1; } And on the server where java is running: command[check_jstat]=sudo su -$someuser -c "/usr/lib/nagios/plugins/check_jstat -p `pgrep java` -w 85 -c 95" – cam Feb 08 '16 at 13:15
  • May be something else is bothering your configuration. Sorry dude, but I won't be able to provide much help to you. – Gaurav Pundir Feb 08 '16 at 13:18
  • i need to know the argument that can be understand by Nagios ... – cam Feb 08 '16 at 13:36

0 Answers0