Page 3 of 4
Re: jstat is failing to show a proper result
Posted: Fri Feb 28, 2020 1:46 am
by runzelpunzel
This is so bizarre
It is indeed! That's why I'm kinda lost and seeking for your help
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.
Re: jstat is failing to show a proper result
Posted: Fri Feb 28, 2020 8:32 am
by scottwilkerson
I wonder if the problem is you need to add the full path to
jstat in the script
When NRPE runs you don't get the full environment for the nagios user, and this could be causing it to fail.
Re: jstat is failing to show a proper result
Posted: Mon Mar 09, 2020 3:11 am
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"
Re: jstat is failing to show a proper result
Posted: Mon Mar 09, 2020 7:08 am
by scottwilkerson
What is the output you get when you run it directly?
Re: jstat is failing to show a proper result
Posted: Mon Mar 09, 2020 8:09 am
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.
Re: jstat is failing to show a proper result
Posted: Mon Mar 09, 2020 8:47 am
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
Re: jstat is failing to show a proper result
Posted: Tue Mar 10, 2020 3:44 am
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>[~]>
Re: jstat is failing to show a proper result
Posted: Tue Mar 10, 2020 3:13 pm
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 $?
Re: jstat is failing to show a proper result
Posted: Wed Mar 11, 2020 9:55 am
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
Re: jstat is failing to show a proper result
Posted: Wed Mar 11, 2020 4:07 pm
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