Nagios plugin in php


#1

Hi,
I just finished a command made in php.

The output is just easy:
if critical
print "CRITICAL - Job has errors"
if ok
print “OK”

In the command line i got: CRITICAL - Job has errors"

But after setup in Nagios i got:

SERVICE STATUS:OK
STATUS INFORMATION: CRITICAL - Job has erros.

what im doing wrong? should i change the ouput?. I tried just “CRIT” or “CRITICAL”.


#2

Nagios considers the exit value, not the text returned.
Never done it in php… in sh it works :slight_smile:

nagiosplug.sourceforge.net/devel … html#AEN76


#3

ok, done.
PHP works great with Nagios
I just ended with exit() instead of die()

Example:
if (warning)
echo “Warning. | perf data=x;b;N;M;”;
exit(1)
if (critical)
echo "CRITICAL"
exit(2)

The normal ending of php (die or exit) returns always “0”


#4

good to know it works :slight_smile:

Thanks.