Code

Add debug option from John Rouillard
authorStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>
Wed, 2 Feb 2005 09:47:45 +0000 (09:47 +0000)
committerStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>
Wed, 2 Feb 2005 09:47:45 +0000 (09:47 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1128 f882894a-f735-0410-b71e-b25c423dba1c

contrib/check_email_loop.pl

index 965f851271233f4d959d60734c8aa21c04013008..7e0a9f0e93f97585ad9b095c63bc6acea6dea789 100644 (file)
@@ -47,10 +47,11 @@ my %ERRORS = ('UNKNOWN' , '-1',
 my $state = "UNKNOWN";
 my ($sender,$receiver, $pophost, $popuser, $poppasswd, $smtphost,$keeporphaned);
 my ($poptimeout,$smtptimeout,$pinginterval,$maxmsg)=(60,60,5,50);
-my ($lostwarn, $lostcrit,$pendwarn, $pendcrit);
+my ($lostwarn, $lostcrit,$pendwarn, $pendcrit,$debug);
 
 # Internal Vars
 my ($pop,$msgcount,@msglines,$statinfo,@messageids,$newestid);
+my (%other_smtp_opts);
 my ($matchcount,$statfile) = (0,"check_email_loop.stat");
 
 # Subs declaration
@@ -70,6 +71,7 @@ alarm($TIMEOUT);
 my $status = GetOptions(
                        "from=s",\$sender,
                        "to=s",\$receiver,
+                        "debug", \$debug,
                         "pophost=s",\$pophost,
                         "popuser=s",\$popuser,
                        "passwd=s",\$poppasswd,
@@ -108,8 +110,14 @@ if (!open STATF, ">$statfile") {
 my $serial = time();
 $serial = "ID#" . $serial . "#$$";
 
+
 # sending new ping email
-my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout) 
+%other_smtp_opts={};
+if ( $debug == 1  ) {
+    $other_smtp_opts{'Debug'} = 1;
+}
+
+my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout, %other_smtp_opts) 
   || nsexit("SMTP connect timeout ($smtptimeout s)",'CRITICAL');
 ($smtp->mail($sender) &&
  $smtp->to($receiver) &&
@@ -233,7 +241,8 @@ sub usage {
   print "   -pendwarn=num      WARNING-state if more than num pending emails\n";
   print "   -pendcrit=num      CRITICAL \n";
   print "   -maxmsg=num        WARNING if more than num emails on POP3 (default 50)\n";
-  print "   -keeporphaned      Set this to NOT delete orphaned E-Mail Ping msg from POP3\n\n";
+  print "   -keeporphaned      Set this to NOT delete orphaned E-Mail Ping msg from POP3\n";
+  print "   -debug             send SMTP tranaction info to stderr\n\n";
   print " Options may abbreviated!\n";
   print " LOST mails are mails, being sent before the last mail arrived back.\n";
   print " PENDING mails are those, which are not. (supposed to be on the way)\n";