Strange problem


Hi nagios-users,

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:


Sending the script to the client.

scp syslog_check nagios@$myhost:/home/nagios/

Running the script on the client.

ssh nagios@$myhost ./syslog_check > “$file”

echo “This is the returned output: .$status.”

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…

Does anyone know what i am doing wrong here?


first idea:
check you have “#!/bin/sh” as the first line of the script and try running it locally as the nagios user



Hi Luca,

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.


Hi dgoyette,

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 :).




Nagios on the nagios server calls the check_syslog script:


Usage: check_syslog hostname

This script must reside in /usr/lib/nagios/plugins/


Sending the client script.

scp syslog_check nagios@$myhost:/home/nagios/

Running the client script on the client.

syslog_status=ssh nagios@$myhost ./syslog_check

Deleting the script on the client in /home/nagios

ssh nagios@$myhost rm -f syslog_check

Interpreting the result.

if “$syslog_status” = “0” ] ; then echo “The syslogproces is oke.”; exit 0; fi

etc… etc… At the interpreting part i return the state through exit 0/1/2/3 which nagios must evaluate.

But the problem is, if i run the script locally myself under nagios, the result of syslog_status=ssh nagios@$myhost ./syslog_check is an integer,

But, if nagios runs it, syslog_status=ssh nagios@$myhost ./syslog_check gives me an empty string…

I hope the problem is clearer now…