[Nagiosplug-devel] Re: Native plugins (was Re: Java Plugins)

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Sun Nov 21 15:32:07 CET 2004


Dear Gentlemen,

I am writing to thank you for your letters and say,

On Fri, Nov 19, 2004 at 07:44:47PM +0100, Jos Visser wrote:

> I would like to venture the guess that the environment that Nagios runs
> in does not contain the PATH, CLASSPATH, SHLIB_PATH, JAVA_HOME or other 
> relevant environment variables.
>

this is almost certainly the clue for this particular instance of an
FAQ problem.

The problem is obviously not Java specific, but related to the 
difference between the CLI environment and that Nagios creates to run 
the plugins (different user etc etc).
 
> ++Jos.es
> 
> On Fri, Nov 19, 2004 at 09:47:02AM -0700 it came to pass that David Robinson wrote:
> > Does anyone on this thread have any experience writing plugins in Java?

.. snip ..
 
> > When I execute my draft Java plugins from the command line as the Nagios
> > user, I get correct output to STDOUT and correct exit codes ... for
> > example:
> > 
> > sh-2.05$ whoami
> > 
> > nagios
> > 
> > sh-2.05$ /home/bea/jdk141_05/bin/java -classpath
> > /usr/lib/nagios/bea_jars/813/weblogic.jar:/usr/lib/nagios/plugins_custom
> > /wls8nagios.jar com.albertsons.nagios.WLS8ThreadMonitor -H lnx074 -P
> > 9193 -u beaprod -p want2gohome -D absCommonWLI -S absCommonWLIMngd1 -M
> > weblogic.kernel.Default
> > 
> > THREADS OK: 1 thread(s) used out of 100
> > 
> > sh-2.05$ echo $?
> > 
> > 0
> > 
> > When the same plugin is called from the Nagios process I receive a
> > message such as below in the nagios.log file:
> > 
> > [1100884674] SERVICE ALERT: lnx112;WLS-812-THREADS;WARNING;SOFT;2;(No
> > output!)
> > 
> > Any idea why I am not receiving any output?  I am writing the status
> > message using System.out.println("THREADS ..."); and
> > System.exit(EXIT_CODE);
> > 

You can nail this sort of plugin error (Ok from CLI, '(No output!)' from 
Nagios) in two ways :-

1 Plugin wrapper

write a script which is called by Nag instead of the problem plugin. 
The script should 

1.1 Run the plugin
1.2 Capture the plugin output and return code (in the 
    manner you have shown from the CLI if you write the wrapper in 
    /bin/sh) and anything else (eg $@) useful to debug the problem
1.3 Append it to a file, output it to syslog etc.

2 With a test Nagios

2.1 gen a new Nag with --enable-DEBUG[whatever]
2.2 gen a stripped down config that runs the prob plugin at a high rate
2.3 install in a private dir
2.4 run Nag from foreground and watch the debug messages

Having said that, Mr Visser has almost certainly got the answer for you.

Yours sincerely.
 

-- 
Stanley Hopcroft

Network specialist, IT Infrastructure
IP Australia
Ph: (02) 6283 3189  Fax: (02) 6281 1353
PO Box 200 Woden  ACT 2606
http://www.ipaustralia.gov.au
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: disclaimer.txt
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20041121/91a6022f/attachment.txt>


More information about the Devel mailing list