Unknown check_spamd.pl plugin status
joseph blase
joseph.mailboxlist at gmail.com
Sat Dec 29 00:59:50 CET 2007
Hi List,
I have this simple plugin that check for spamd availability on my
mailservers, but apparently the service status on webui is always
unknown.Running it manually on CLI return success.
nagios:/usr/lib/nagios/plugins# ./check_spamd.pl mailgw
OK
Don't have an nrpe installed if ever that would matter. Object commands and
host had been also defined. Appreciate for any tips.
below is the actual script:
nagios:/usr/lib/nagios/plugins# more check_spamd.pl
#!/usr/bin/perl -w
#=for Information:
#Program to check to make sure spamd is running and report back to nrpe for
#nagios.
#Created: 11/29/2006
#Version: 1.2
#Revised: 12/03/2006
#Revised by: Erinn Looney-Triggs
#Author: Erinn Looney-Triggs
#=cut
#
use strict; #Do it right
use Switch; #Standard perl 5.8 module to use switch
statement
use POSIX qw( WIFEXITED ); #Fix system call's strange return values
my $spamc = "/usr/bin/spamc"; #Location of spamc
my $hostname=$ARGV[0];
#
#Make sure spamc exists and if not give back a nagios warning
if ( !-e $spamc ){
print "The $spamc program does not exist.\n";
exit 3;
}
#The command to be run
my $cmd = "echo foo | $spamc -x -c -t 10 -d $hostname > /dev/null";
#Run the command
WIFEXITED(system ($cmd)) or die "Couldn't run $cmd\n";
#
# #Divide by 256 or bitshift right by 8 to get the original error
code
my $return_value = $? >> 8;
#
# #Parse the errors and give Nagios parsible error codes and messages
switch ($return_value){
case 0 {print "OK\n"; exit 0;}
case 64 {print "Command line usage error\n"; exit 1;}
case 65 {print "Data format error\n"; exit 1;}
case 66 {print "Cannot open input\n"; exit 1;}
case 67 {print "Addressee unknown\n"; exit 1;}
case 68 {print "Host name unknown\n"; exit 1;}
case 69 {print "Spamd service unavailable\n"; exit 2;}
case 70 {print "Internal software error\n"; exit 2}
case 71 {print "System error (e.g., can't fork)\n"; exit 2;}
case 72 {print "Critical OS file missing\n"; exit 2;}
case 73 {print "Can't create (user) output file\n"; exit 1;}
case 74 {print "Input/output error\n"; exit 1;}
case 75 {print "Temp failure; user is invited to retry\n";
exit 1;}
case 76 {print "Remote error in protocol\n"; exit 2;}
case 77 {print "Permission denied\n"; exit 1;}
case 78 {print "Configuration error\n"; exit 1;}
else {print "An unknown error has occured in $spamc\n";
exit 3}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20071228/0b72163a/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-------------- next part --------------
_______________________________________________
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