=================================================================== RCS file: /cvs/nagios/check_email/check_email,v retrieving revision 1.1 retrieving revision 1.3 diff -u -r1.1 -r1.3 --- nagios/check_email/check_email 2006/08/29 23:28:49 1.1 +++ nagios/check_email/check_email 2006/10/18 16:39:18 1.3 @@ -11,7 +11,7 @@ # # 11.15.2003 Version 1.0 # -# $RedRiver$ +# $RedRiver: check_email,v 1.2 2006/09/27 18:54:27 andrew Exp $ use POSIX; use lib "/usr/local/libexec/nagios" ; @@ -82,7 +82,7 @@ if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1.1 $ '); + print_revision($PROGNAME,'$Revision: 1.3 $ '); exit $ERRORS{'OK'}; } @@ -100,7 +100,7 @@ ### Actions go here my $subject = scalar localtime; -my $recieved_subject; +my $received_subject; $smtp_server ||= $hostname; $pop_server ||= $hostname; @@ -108,7 +108,7 @@ my $smtp = Net::SMTP->new($smtp_server) || done('CRITICAL', "Couldn't connect to SMTP Server $smtp_server"); -$smtp->mail($from_address) || done('CRITICAL', "Couldn't specify smtp from address $from_address on SMTP server $smtp_server"); +$smtp->mail($from_address) || done('WARNING', "Couldn't specify smtp from address $from_address on SMTP server $smtp_server"); $smtp->to($to_address) || done('CRITICAL', "Couldn't specify smtp to address $to_address on SMTP server $smtp_server"); $smtp->data() || done('CRITICAL', "Couldn't begin data on SMTP server $smtp_server"); @@ -137,7 +137,7 @@ foreach my $line ( @{ $lines } ) { #print $line; if ( $line =~ /^Subject:\s+(.*)$/o ) { - $recieved_subject = $1; + $received_subject = $1; last; } } @@ -146,14 +146,17 @@ $pop->quit() || done('CRITICAL', "Couldn't quit from POP server $pop_server"); #print "Subject: $subject\n"; -#print "Recieved: $recieved_subject\n"; +#print "Received: $received_subject\n"; -if ($subject eq $recieved_subject) { +if (not defined $received_subject) { + $state = "WARNING"; + $answer = "No subject line received"; +} elsif ($subject eq $received_subject) { $state = "OK"; - $answer = "Sent and recieved message correctly"; + $answer = "Sent and received message correctly"; } else { $state = "WARNING"; - $answer = "Subject lines did not match wrong message recieved"; + $answer = "Subject lines did not match wrong message received"; } done($state, $answer); @@ -181,9 +184,9 @@ print "status of email flow on the target host.\n"; print "It sends an e-mail to a test user, and then checks \n"; print "a POP account. Failing at any point during if there is \n"; - print "a problem. It gives a WARNING if the mail is not recieved \n"; + print "a problem. It gives a WARNING if the mail is not received \n"; print "in time, and gives a CRITICAL if it cannot connect to any \n"; - print "services. Do not use an account that you want to recieve \n"; + print "services. Do not use an account that you want to receive \n"; print "mail from. This program will delete ALL mail in the mailbox \n"; print "that you specify."; print "\n"; @@ -196,6 +199,6 @@ print " -t (--to) Address to send mail to, defaults to --username\@--hostname\n"; print " -f (--from) Address to send mail from, defaults to Nagios <>\n"; print " -w (--wait) Time (in seconds) to wait between sending the mail and checking for it, defaults to 1 second. \n"; - print_revision($PROGNAME, '$Revision: 1.1 $'); + print_revision($PROGNAME, '$Revision: 1.3 $'); }