diff options
author | Jan Wagner <waja@cyconet.org> | 2013-10-01 12:43:39 +0200 |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2014-01-29 13:45:36 +0100 |
commit | 2dc150da81169ec6d81858478b6203eb3aa164a9 (patch) | |
tree | 3d844b122cd99bddd3378b6e76fdeb601ed7d62b /plugins-scripts | |
parent | 297d0535c2767d7f6936747587b28cea96dc4e2f (diff) | |
download | monitoring-plugins-2dc150da81169ec6d81858478b6203eb3aa164a9.tar.gz |
check_mailq: adding nullmailer support
Adding nullmailer support to check_mailq submitted by Luca Corti
Closes: #740
Closes: #1189
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-x | plugins-scripts/check_mailq.pl | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index 9de8f02b..2a805b62 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl | |||
@@ -500,6 +500,43 @@ elsif ( $mailq eq "exim" ) { | |||
500 | } | 500 | } |
501 | } # end of ($mailq eq "exim") | 501 | } # end of ($mailq eq "exim") |
502 | 502 | ||
503 | elsif ( $mailq eq "nullmailer" ) { | ||
504 | ## open mailq | ||
505 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | ||
506 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | ||
507 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
508 | exit $ERRORS{'UNKNOWN'}; | ||
509 | } | ||
510 | }elsif( defined $utils::PATH_TO_MAILQ){ | ||
511 | unless (-x $utils::PATH_TO_MAILQ) { | ||
512 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
513 | exit $ERRORS{'UNKNOWN'}; | ||
514 | } | ||
515 | } else { | ||
516 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | ||
517 | exit $ERRORS{'UNKNOWN'}; | ||
518 | } | ||
519 | |||
520 | while (<MAILQ>) { | ||
521 | #2006-06-22 16:00:00 282 bytes | ||
522 | |||
523 | if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-2][0-9]\:[0-2][0-9]\s{2}[0-9]+\sbytes$/) { | ||
524 | $msg_q++ ; | ||
525 | } | ||
526 | } | ||
527 | close(MAILQ) ; | ||
528 | if ($msg_q < $opt_w) { | ||
529 | $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; | ||
530 | $state = $ERRORS{'OK'}; | ||
531 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { | ||
532 | $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)"; | ||
533 | $state = $ERRORS{'WARNING'}; | ||
534 | }else { | ||
535 | $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)"; | ||
536 | $state = $ERRORS{'CRITICAL'}; | ||
537 | } | ||
538 | } # end of ($mailq eq "nullmailer") | ||
539 | |||
503 | # Perfdata support | 540 | # Perfdata support |
504 | print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n"; | 541 | print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n"; |
505 | exit $state; | 542 | exit $state; |
@@ -559,7 +596,7 @@ sub process_arguments(){ | |||
559 | } | 596 | } |
560 | 597 | ||
561 | if (defined $opt_M) { | 598 | if (defined $opt_M) { |
562 | if ($opt_M =~ /^(sendmail|qmail|postfix|exim)$/) { | 599 | if ($opt_M =~ /^(sendmail|qmail|postfix|exim|nullmailer)$/) { |
563 | $mailq = $opt_M ; | 600 | $mailq = $opt_M ; |
564 | }elsif( $opt_M eq ''){ | 601 | }elsif( $opt_M eq ''){ |
565 | $mailq = 'sendmail'; | 602 | $mailq = 'sendmail'; |
@@ -591,7 +628,7 @@ sub print_help () { | |||
591 | print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n"; | 628 | print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n"; |
592 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; | 629 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; |
593 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; | 630 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; |
594 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n"; | 631 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = sendmail)\n"; |
595 | print "-h (--help)\n"; | 632 | print "-h (--help)\n"; |
596 | print "-V (--version)\n"; | 633 | print "-V (--version)\n"; |
597 | print "-v (--verbose) = debugging output\n"; | 634 | print "-v (--verbose) = debugging output\n"; |