Discussion:
[Nagios-users] JMX plugin
Ryan Gravener
2008-02-25 22:23:08 UTC
Permalink
I have modified this plugin:

http://www.nagiosexchange.org/Misc.54.0.html?&tx_netnagext_pi1%5Bp_view%5D=808

a little bit. Added authentication and changed the output format.

The plugin executes from the command line fine, but on the nagios server I get:

Heap UNKNOWN 02-25-2008 22:08:22 0d 2h 12m 8s 4/4 NRPE: Unable to
read output

on the machine I execute the command described in nrpe.cfg

command[check_heap]=/usr/lib/nagios/plugins/check_jmx -U
service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi -O
java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J
used -vvvv -w 731847066 -c 1045495808 -username joe -password doe

which outputs:

JMX OK - HeapMemoryUsage.used is
78707376,committed=1063321600;init=1073741824;max=1063321600;used=78707376


I think the output is legal, and my settings are ok. But perhaps the
command arguments are not passing correctly since a shell script is
calling the java jar:

#!/bin/sh
#
# Nagios plugin to monitor Java JMX (http://java.sun.com/jmx)attributes.
#
RDIR=`dirname $0`
java -cp $RDIR/jmxquery.jar jmxquery.JMXQuery $@

Thanks,
--
Ryan Gravener
http://ryangravener.com
Oliver Welter
2008-02-26 06:02:15 UTC
Permalink
Hi Rya,n
Post by Ryan Gravener
JMX OK - HeapMemoryUsage.used is
78707376,committed=1063321600;init=1073741824;max=1063321600;used=78707376
IIRC, your output must start with the status keyword, so you have to
remove the "JMX" in front of the ok.

Another common pitfall are insufficient rights - have you tried running
the script with the rights of the nrpe user?

Oliver
- --
Protect your environment - close windows and adopt a penguin!
PGP-Key: 3B2C 8095 A7DF 8BB5 2CFF 8168 CAB7 B0DD 3985 1721
Hari Sekhon
2008-02-26 18:08:32 UTC
Permalink
Post by Oliver Welter
Post by Ryan Gravener
JMX OK - HeapMemoryUsage.used is
78707376,committed=1063321600;init=1073741824;max=1063321600;used=78707376
IIRC, your output must start with the status keyword, so you have to
remove the "JMX" in front of the ok
Really? I never got that from the Nagios development guidelines, perhaps

SERVICE STATUS: Information text

is slightly ambiguous as it could mean "SERVICENAME then STATUS then
Information text" or just "STATUS then Information text".

I've personally always preferred the former where you print the check
name, I think it makes things clearer and I've noticed that lots of the
plugins from the standard distribution follow this.


To the OP and back on topic, I don't know anything about your plugin but
have you tested that this Java program is using the right Exit codes?
You should also make sure that all output goes to stdout and not stderr
since nagios does not catches stderr.

Oliver is right, you should check the user that you are running it as,
one common mistake is to run a program as root from the command line and
then wonder why it doesn't work as the nagios user.

Usually when you get Unknown and no output at the same time with nrpe,
it's usually a user issue or a failure to execute issue due to wrong
path or requiring more privs or something hanging like a sudo call where
you hadn't granted nopasswd so it prompted, hung and timed out.

You should also check out
http://nagiosplug.sourceforge.net/developer-guidelines.html for the
development guidelines.

-h
--
Hari Sekhon
Marc Powell
2008-02-26 19:13:29 UTC
Permalink
-----Original Message-----
Sent: Tuesday, February 26, 2008 12:09 PM
To: Oliver Welter
Subject: Re: [Nagios-users] JMX plugin
Post by Oliver Welter
Post by Ryan Gravener
JMX OK - HeapMemoryUsage.used is
78707376,committed=1063321600;init=1073741824;max=1063321600;used=787073
76
Post by Oliver Welter
IIRC, your output must start with the status keyword, so you have to
remove the "JMX" in front of the ok
Really? I never got that from the Nagios development guidelines,
perhaps
SERVICE STATUS: Information text
is slightly ambiguous as it could mean "SERVICENAME then STATUS then
Information text" or just "STATUS then Information text".
The plugin output text is completely arbitrary. Nagios only really cares
about the exit code and that there's only one line of plugin output,
whatever it is.

--
Marc
Hari Sekhon
2008-02-27 09:45:30 UTC
Permalink
Post by Marc Powell
The plugin output text is completely arbitrary. Nagios only really cares
about the exit code and that there's only one line of plugin output,
whatever it is
Yes quite right, but standardization of output is nice for coherence and
to give a more professional unified feel.

Do you have any preference between the two? There seems to unfortunately
be a mix between the two styles.

Perhaps the official development guidelines could be adjusted to steel
people towards one standard output format on this?

I'd vote for the "SERVICENAME SERVICESTATUS: Informational text" format
like "DISK OK: / is 50% full" ...

-h
--
Hari Sekhon
k***@gmail.com
2008-02-27 12:58:41 UTC
Permalink
My $0.02:

plug-in output isn't completely arbitrary if you plan on processing
performance data.

considering that a single defined command can be turned into multiple
services (assuming you use $ARG$ variables) I don't think printing the
servicename would be helpful. The servicename is already available in
both the web and notification output too.

-Kyle
Post by Hari Sekhon
Post by Marc Powell
The plugin output text is completely arbitrary. Nagios only really cares
about the exit code and that there's only one line of plugin output,
whatever it is
Yes quite right, but standardization of output is nice for coherence and
to give a more professional unified feel.
Do you have any preference between the two? There seems to unfortunately
be a mix between the two styles.
Perhaps the official development guidelines could be adjusted to steel
people towards one standard output format on this?
I'd vote for the "SERVICENAME SERVICESTATUS: Informational text" format
like "DISK OK: / is 50% full" ...
-h
--
Hari Sekhon
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nagios-users mailing list
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting
any issue.
::: Messages without supporting info will risk being sent to /dev/null
Holger Weiss
2008-02-27 13:14:28 UTC
Permalink
I don't think printing the servicename would be helpful. The
servicename is already available in both the web and notification
output too.
I agree, see the thread I started on this topic some time ago in
nagiosplug-devel@:

http://thread.gmane.org/gmane.network.nagios.plugins.devel/5155

While I'd also omit the status from the output, others would rather keep
that or prefer to also keep the service name. So, we thought the best
solution would be to make the output format configurable at build time,
which I've implemented[*] but not yet committed.

Holger

[*] http://article.gmane.org/gmane.network.nagios.plugins.devel/5179
Marc Powell
2008-02-27 13:17:48 UTC
Permalink
Post by k***@gmail.com
plug-in output isn't completely arbitrary if you plan on processing
performance data.
Sure, and there are other caveats as well but they weren't germane to
the original context that I replied to.
Post by k***@gmail.com
considering that a single defined command can be turned into multiple
services (assuming you use $ARG$ variables) I don't think printing the
servicename would be helpful. The servicename is already available in
both the web and notification output too.
The service_description and service the plugin is checking can be
completely different. Both are useful information.

--
Marc
Marc Powell
2008-02-27 13:20:50 UTC
Permalink
Post by Hari Sekhon
Post by Marc Powell
The plugin output text is completely arbitrary. Nagios only really cares
about the exit code and that there's only one line of plugin output,
whatever it is
Yes quite right, but standardization of output is nice for coherence and
to give a more professional unified feel.
Yup, that's why guidelines exist.
Post by Hari Sekhon
Do you have any preference between the two? There seems to
unfortunately
be a mix between the two styles.
I'd vote for the "SERVICENAME SERVICESTATUS: Informational text" format
like "DISK OK: / is 50% full" ...
I use this format in plugins I write.

--
Marc
Hari Sekhon
2008-02-27 13:44:26 UTC
Permalink
Post by Marc Powell
Post by Hari Sekhon
Yes quite right, but standardization of output is nice for coherence and
to give a more professional unified feel.
Yup, that's why guidelines exist.
Post by Hari Sekhon
Do you have any preference between the two? There seems to
unfortunately
be a mix between the two styles.
I'd vote for the "SERVICENAME SERVICESTATUS: Informational text" format
like "DISK OK: / is 50% full" ...
I use this format in plugins I write
I'm glad to hear that, I too write my plugins this way. I prefer this
format as it's very clear and most of the plugins that I use from the
std distribution seem to do this.

I was thinking that a switch on each plugin to change the prefix on the
output depending on your preferences might be the best thing to satisfy
all, that way you can adjust all plugins to match one way or the other.
You could use this to specify "" to change it to have no prefix if needed.

-h
--
Hari Sekhon
Chris Lee
2008-03-06 03:07:32 UTC
Permalink
Hi Ryan

You mentioned that you modified check_jmx so that it can take authentication argument. Do you mind showing us the code for doing that?

Thanks very much,

- Chris Lee (cleegt)

-----------------------
This thread is located in the archive at this URL:
http://www.nagiosexchange.org/nagios-users.34.0.html?&tx_maillisttofaq_pi1[showUid]=9677
Ryan Gravener
2008-03-06 04:07:29 UTC
Permalink
Sure, I made a google code project:

http://code.google.com/p/jmxquery/source/browse/trunk/src/main/java/jmxquery/JMXQuery.java

And here is the auth code:

if(username!=null) {
Map m = new HashMap();
m.put(JMXConnector.CREDENTIALS,new String[]
{username,password});
connector = JMXConnectorFactory.connect(jmxUrl,m);
} else {
connector = JMXConnectorFactory.connect(jmxUrl);
}
Post by Chris Lee
Hi Ryan
You mentioned that you modified check_jmx so that it can take authentication argument. Do you mind showing us the code for doing that?
Thanks very much,
- Chris Lee (cleegt)
-----------------------
http://www.nagiosexchange.org/nagios-users.34.0.html?&tx_maillisttofaq_pi1[showUid]=9677
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nagios-users mailing list
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
--
Ryan Gravener
http://ryangravener.com
Chris Lee
2008-03-06 15:17:49 UTC
Permalink
Hi Ryan

Thanks a lot for your sharing. I am able to use your code in google to make it work on my system :)

Best Regards,

- Chris Lee (cleegt)

-----------------------
This thread is located in the archive at this URL:
http://www.nagiosexchange.org/nagios-users.34.0.html?&tx_maillisttofaq_pi1[showUid]=9998
Loading...