jstat is failing to show a proper result

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.
runzelpunzel
Posts: 16
Joined: Thu Jul 05, 2018 2:14 am

Re: jstat is failing to show a proper result

Post by runzelpunzel »

This is so bizarre
It is indeed! That's why I'm kinda lost and seeking for your help :D

Code: Select all

ls -l /usr/lib/nagios/plugins/check_test.sh

-rwxr-xr-x 1 root root 199 Feb 21 08:19 /usr/lib/nagios/plugins/check_test.sh
Looks okay to me!?


PS: I will be AFK in the following week, so any further test / comment will be written after March, 9th.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: jstat is failing to show a proper result

Post by scottwilkerson »

I wonder if the problem is you need to add the full path to jstat in the script

Code: Select all

which jstat
When NRPE runs you don't get the full environment for the nagios user, and this could be causing it to fail.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
runzelpunzel
Posts: 16
Joined: Thu Jul 05, 2018 2:14 am

Re: jstat is failing to show a proper result

Post by runzelpunzel »

It's the default /usr/bin/jstat.
Even when I run a /usr/bin/sudo /usr/bin/jstat -gc 16652, whereas 16652 is the PID of my java process, I get a proper result.
However, when I run configure

Code: Select all

command[check_sudo_test4]=/usr/bin/sudo /usr/bin/jstat -gc 16652
in /etc/nagios/nrpe.cfg and call check_sudo_test4 via NRPE from the nagios server, i get an "NRPE: Unable to read output"
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: jstat is failing to show a proper result

Post by scottwilkerson »

What is the output you get when you run it directly?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
runzelpunzel
Posts: 16
Joined: Thu Jul 05, 2018 2:14 am

Re: jstat is failing to show a proper result

Post by runzelpunzel »

the regular output from jstat, eg.

Code: Select all

 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT 
45056.0 45568.0  0.0   24537.4 1306112.0 914401.5 1668096.0  1393081.2  574832.0 506528.5 79048.0 65307.1   2629  226.672  17     12.857  239.529
Looking into that, "unable to read output" might well be a vaild answer (as we've a multi-line-output, etc.).
This is a very basic testing-script, as the previous tests that were writing to a file an parse the output from jstat didn't work either.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: jstat is failing to show a proper result

Post by scottwilkerson »

I'm not really familiar with jstat but if it gives couninuous updates you may need to add the "count" number to the end "1"
Re: https://docs.oracle.com/javase/7/docs/t ... jstat.html

Code: Select all

command[check_sudo_test4]=/usr/bin/sudo /usr/bin/jstat -gc 16652 1
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
runzelpunzel
Posts: 16
Joined: Thu Jul 05, 2018 2:14 am

Re: jstat is failing to show a proper result

Post by runzelpunzel »

No, it really runs just one time:

Code: Select all

nagios@<MYMACHINE>[~]> /usr/bin/sudo /usr/bin/jstat -gc 16652
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT 
24064,0 38400,0 23785,2  0,0   1090560,0 323405,2 1622016,0  1587494,2  578800,0 509547,1 79432,0 65639,8   3436  288,142  18     13,699  301,841
nagios@<MYMACHINE>[~]>
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: jstat is failing to show a proper result

Post by scottwilkerson »

Curious, what output do you get when you run

Code: Select all

/usr/bin/sudo /usr/bin/jstat -gc 16652 2> /dev/null
echo $?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
runzelpunzel
Posts: 16
Joined: Thu Jul 05, 2018 2:14 am

Re: jstat is failing to show a proper result

Post by runzelpunzel »

"0", as you would expect.

Code: Select all

nagios@<MYMACHINE>[~]> /usr/bin/sudo /usr/bin/jstat -gc 16652 2> /dev/null
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
17408,0 9216,0  0,0   9188,3 446976,0 325530,5 1664000,0  1205941,3  585968,0 515763,0 80200,0 66246,9   5507  437,466  25     20,204  457,670
nagios@<MYMACHINE>[~]> echo $?
0
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: jstat is failing to show a proper result

Post by scottwilkerson »

I am really at a loss here why your check_sudo_test4 isn't working...

Looking around for similar usage I did find the following plugin that it looks like others are using that may do something similar
https://exchange.nagios.org/directory/P ... at/details
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked