[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netsaint-users
Subject:    Re: [netsaint] Re: POP check plugin?
From:       Andre Olivo <andre.olivo () uol ! com ! br>
Date:       2003-02-14 10:26:51
[Download RAW message or body]

Hello

The default check_pop plugin only opens port 110, but doesn't send any
string.

If you want a complete pop3 check, use the one attached to this email.
This one is derived from the second part of a complete mailloop plugin
that come with the netsaint_plugins package. I think it's on the contrib
directory.

Warning: it needs the user password in the parameters, so think about
security before using it.

Warning2: it need some extra perl modules to do the work

[]s



On Thu, 2003-02-13 at 13:47, Karl DeBisschop wrote:
> Katherine Cerqueira writes: 
> 
> > Hi Everyone, 
> > 
> > Do you know of a netsaint plugin that will do pop check on a mail server?
> > Basically, what I'm looking for is for netsaint to connect port 110 of our
> > mail server, and test it by sending a username and password .  If it fails
> > to authenticate, then it will alert us.  
> 
> get check_pop from the nagios plugins (it's actually just a link to 
> check_tcp, but does what you want). 
> 
>  --
> Karl 
> 
> 
> -------------------------------------------------------
> This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
> are you planning your Web Server Security? Click here to get a FREE
> Thawte SSL guide and find the answers to all your  SSL security issues.
> http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
> _______________________________________________
> Netsaint-users mailing list
> Netsaint-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/netsaint-users



["check_pop.pl" (check_pop.pl)]

#!/usr/bin/perl 

use Net::POP3;
use strict;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');


my $TIMEOUT = 120;
my %ERRORS = ('UNKNOWN' , '-1',
              'OK' , '0',
              'WARNING', '1',
              'CRITICAL', '2');

my $state = "OK";
my ($popuser, $poppasswd, $pophost, $popport, $answer, $i);
my ($warning, $critical, $timeout)=(10,20,30);

# Internal Vars
my ($pop,$qtdemsg,$msgcount,@msglines);


# Subs declaration
sub usage;
sub messagematchs;
sub nsexit;


# Just in case of problems, let's not hang NetSaint
$SIG{'ALRM'} = sub {
     print ("ERROR: $0 Time-Out $TIMEOUT s \n");
     exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);

# Evaluate Command Line Parameters
my $status = GetOptions(
                        "pophost=s",\$pophost,
                        "popport=s",\$popport,
                        "popuser=s",\$popuser,
                        "poppasswd=s",\$poppasswd,
                        "warning=i",\$warning,
                        "critical=i",\$critical,
                        "timeout=i",\$timeout,
                        );
usage() if ($status == 0 || ! ($pophost && $popuser && $poppasswd ));

my $initialtime=time();
$pop = Net::POP3->new( $pophost, 
                 Timeout=>$timeout,
                 Port=>$popport) 
       || nsexit("POP3 connect timeout (>$timeout s, host: $pophost)",'CRITICAL');

$msgcount=$pop->login($popuser,$poppasswd);

nsexit("POP3 login failed (user:$popuser)",'CRITICAL') if (!defined($msgcount));

for ($i=1;$i<=$msgcount;$i++) 
{
  @msglines = @{$pop->get($i)};
  $pop->delete($i);  # remove E-Mail from POP3 server
}
$pop->quit();  # necessary for pop3 deletion!


my $ellaptime=time()-$initialtime;
if ($ellaptime<$warning)
{
   $answer = "OK! $msgcount messages. Ellapsed $ellaptime s\n";
}
elsif ($ellaptime<$critical)
{
   $answer = "WARNING! $msgcount messages. Ellapsed $ellaptime s\n";
   $state = "WARNING";
}
else
{
   $answer = "CRITICAL! $msgcount messages. Ellapsed $ellaptime s\n";
   $state = "CRITICAL";
}

# Exit in a Netsaint-compliant way
nsexit($answer,$state);


# ----------------------------------------------------------------------

sub usage {
	print "Usage: check_pop.pl -popuser=[USER] -poppasswd=[PASSWORD]\n";
	print "                    -pophost=[POP3 SERVER]\n";
	print "                    -warning=[seconds]\n";
	print "                    -critical=[seconds]\n";
	print "                    -timeout=[seconds]\n";
	exit $ERRORS{"UNKNOWN"};
}

sub nsexit {
  my ($msg,$code) = @_;
  $code=$state if (!defined $code);
  print "$code: $msg\n" if (defined $msg);
  exit $ERRORS{$code};
}


-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
_______________________________________________
Netsaint-users mailing list
Netsaint-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/netsaint-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic