I am encountering a strange problem while configuring and using Nagios (nagios-1.2-2.1). I have written several scripts/plugins which i want to store on a local nagios server, this is the machine which runs nagios. I have several clients in the network which i want to monitor. In the plugins on the nagios server (/usr/lib/nagios/plugins) i do the following:
So i scp the scripts to the client, run them there, and in those scripts i echo an integer (0-10) which will be evaluated in the script on the nagios server.
The problem is that this doesn’t seem to be working if i use nagios. It works great if i run it in bash, but if i run it in nagios, for some reason the return value is always “”. So it only gives me an empty string back…
When i ran it in shell it was under the nagios user and that works perfect. And yes, every script has # !/bin/sh as the first line.
The point is that running it in bash as the nagios user works fine, i can see it get’s a result back from the remote script. But when nagios runs it it seems like the remote script returns “”.
Try supplying the full path to echo. Probably /bin/echo.
Also, unrelated, but important, make sure your script is actually exiting with the exit code you want (0-3) or nagios will not evaluate the check properly.
The script wich runs remote has to supply an integer, 1 tot n. That integer must be interpreted by the script on the nagios server. And that script, on the nagios server, check the integer against a certain state and exits accordingly. That works fine, but the problem is the communication between the two scripts.
But i will try the /bin/echo. Maybe that will help :).