[Nagiosplug-help] Re: check_pop and login
Moshe Sharon
moshesharon at gmail.com
Tue Aug 30 05:25:33 CEST 2005
Hello
ive written a small perl script to do this. which uses the POP3Client.pm perl
module which you can get from http://search.cpan.org/~sdowd/Mail-POP3Client-
2.17/.
the script:
#!/usr/bin/perl
# POP3/POP3s check script for nagios
# Created By Moshe Sharon.
use Mail::POP3Client;
$host = $ARGV[0];
$user = $ARGV[1];
$password = $ARGV[2];
$usessl = $ARGV[3];
if ($#ARGV != 3) {
print "Usage: check_pop3.pl HOST USER PASS USESSL(Yes/No)\n";
exit 1;
}
if ($usessl eq "Y" || $usessl eq "Yes" ) {
$proto = "POP3s";
$pop = new Mail::POP3Client( USER => "$user",
PASSWORD => "$password",
HOST => "$host",
TIMEOUT => 10,
USESSL => true );
}else{
$proto = "POP3";
$pop = new Mail::POP3Client( USER => "$user",
PASSWORD => "$password",
TIMEOUT => 10,
HOST => "$host");
}
$count = $pop->Count();
if ($count == -1 ) {
print "$proto CRITICAL. Cant Login [User: $user]\n";
$pop->Close();
exit 2;
}else{
print "$proto OK [$count Messages at $user]\n";
$pop->Close();
exit 0;
}
### END SCRIPT
checkcommand syntax is:
command_line $USER1$/check_pop3_ssl.pl $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
service check command: check_pop3_login!nagios4!nagiosAb14!no
note that it is not written with standard nagios plugin method but it does the
trick.
it's working in our production server for several month now. but as mentioned
its free software so use at your own risk.
Hope it helped
Moshe Sharon
More information about the Help
mailing list