plugins with rsh

Marc Powell marc at ena.com
Fri Jan 5 01:05:34 CET 2007



> -----Original Message-----
> From: nagios-users-bounces at lists.sourceforge.net [mailto:nagios-users-
> bounces at lists.sourceforge.net] On Behalf Of dave stern - e-
> mail.pluribus.unum
> Sent: Thursday, January 04, 2007 2:28 PM
> To: nagios-users at lists.sourceforge.net
> Subject: Re: [Nagios-users] plugins with rsh
> 

[much of a very badly quoted thread removed]

> 
> These were both great suggestions. Here's where I stand now (hopefully
> this can help others altho this
> isn't yet resolved)
> 
> nagios user has a csh. I can either change that or get around it by
> prepending to the nagios command /usr/bin/sh
> Also, rsh interprets two dollars as PID eg if I
> Linux1> rsh hostname 'date; echo $$?'
> Thu Jan  4 12:38:36 EST 2007
> 12344
> 
> Turns out, it will interpret $status correctly ie
> Linux1> rsh hostname 'date; echo $status'
> Thu Jan  4 12:38:36 EST 2007
> 0
> 
> >linux1> rsh hostname 'bogus; echo $status'
> bogus; Command not found
> 1
> 
> (Hope I got that right, manufacturing this from memory as nagios
network
> is airgapped to internet)
> 
> The problem is still getting the info back to nagios. Putting the
above
> command into nagios's command.cfg
> and setting up two such services, one on a host that will report
success
> and one on a host that will fail, I get
> both hosts reporting "(No output!) in the far right nagios column. If
I
> remove everything after the semicolon,
> the command runs and the output is correct but the status code isn't
> returned thus the service color isn't
> updated. Changing "echo $status" to "echo $$status" also makes no
> difference so nagios appears to be
> choking on the two commands (ie when it hits the ";")
> 

That's correct. The status will never be set right because the status is
never obtained from the text output of the command that's being run.
Nagios expects the command that it runs to be a plugin that conforms to
the nagios plugin API (http://nagiosplug.sf.net - Developer Guidelines).
rsh isn't a plugin and doesn't return output in the format that Nagios
expects; specifically rsh's exit code is not appropriate and that's the
only one nagios pays attention to. rsh is running successfully so it's
standard exit code is 0. That just happens to correspond with the API
code for an OK status to nagios. 

What you'll need to do is create a wrapper shell script that calls rsh,
echo's one line of output for nagios to use for display purposes and
exits with an exit() code appropriate to the nagios status. This shell
script would be the plugin command{} that you call. For the simplest of
plugins you only need to conform to these two API requirements --

http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN34 - one
line of text
http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN77 -
proper exit code

HTH

--
Marc


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
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





More information about the Users mailing list