Re: Jacobs, Eric 2009-10-14 <E4674276443CFB4BBDE56855AF2E4A46045324A4 at tciexch2.tci.loc>
Apparently, last night our Exchange server stopped receiving email until it was rebooted this morning. Everyone is up in arms. Hobbit showed nothing unusual. Does anyone have any way to monitor Exchange?
We've got some cronjob that sends mail to an Exchange account every 5 minutes and a simple perl script using Net::IMAP checking if the last mail received is not older than some timeout. (Using Hobbit.pm from the Debian package.)
#!/usr/bin/perl -w
use strict; use Net::IMAP::Simple::SSL; use Date::Parse; use Hobbit;
my $bb = new Hobbit ({ hostname => 'smtp.xx.com', test => 'mailping'});
sub check_imap ($$$) { my ($servername, $username, $password) = @_; my $server = new Net::IMAP::Simple::SSL ($servername);
unless ($server->login ($username, $password)) {
$bb->color_line ('red', "IMAP error: $servername: ". $server->errstr . "\n");
return;
}
my $now = time ();
my $max = 0;
my $number_of_messages = $server->select ('INBOX');
foreach my $msg ( 1..$number_of_messages ) {
my $lines = join '', @{$server->get ($msg)};
next unless $lines =~ /^Subject: ping (.*)/m;
my $time = str2time ($1);
$max = $time if $time > $max;
if ($time < $now - 7200) {
$server-> delete ($msg);
}
}
$server->quit();
my $color;
if ($max > $now - 400) {
$color = 'green';
} elsif ($max > $now - 700) {
$color = 'yellow';
} else {
$color = 'red';
}
$bb->color_line ($color, "Last ping mail at $servername was received at ".scalar (localtime ($max)) ."\n");
}
check_imap ('imap.xx.com', 'hobbit', 'passwd');
$bb->send;
Christoph
cb at df7cb.de | http://www.df7cb.de/