diff options
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-x | plugins-scripts/check_mailq.pl | 145 |
1 files changed, 69 insertions, 76 deletions
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index abdc7736..f143c6fa 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl | |||
@@ -83,20 +83,19 @@ alarm($opt_t); | |||
83 | # switch based on MTA | 83 | # switch based on MTA |
84 | 84 | ||
85 | if ($mailq eq "sendmail") { | 85 | if ($mailq eq "sendmail") { |
86 | if( ! $utils::PATH_TO_MAILQ) { | ||
87 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | ||
88 | exit $ERRORS{'UNKNOWN'}; | ||
89 | } | ||
90 | |||
91 | if ( ! -x $utils::PATH_TO_MAILQ) { | ||
92 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
93 | exit $ERRORS{'UNKNOWN'}; | ||
94 | } | ||
86 | 95 | ||
87 | ## open mailq | 96 | ## open mailq |
88 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 97 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
89 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { | 98 | print "ERROR: could not open $sudo $utils::PATH_TO_MAILQ \n"; |
90 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
91 | exit $ERRORS{'UNKNOWN'}; | ||
92 | } | ||
93 | }elsif( defined $utils::PATH_TO_MAILQ){ | ||
94 | unless (-x $utils::PATH_TO_MAILQ) { | ||
95 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
96 | exit $ERRORS{'UNKNOWN'}; | ||
97 | } | ||
98 | } else { | ||
99 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | ||
100 | exit $ERRORS{'UNKNOWN'}; | 99 | exit $ERRORS{'UNKNOWN'}; |
101 | } | 100 | } |
102 | # single queue empty | 101 | # single queue empty |
@@ -224,7 +223,6 @@ if ($mailq eq "sendmail") { | |||
224 | 223 | ||
225 | } | 224 | } |
226 | 225 | ||
227 | |||
228 | ## close mailq | 226 | ## close mailq |
229 | close (MAILQ); | 227 | close (MAILQ); |
230 | 228 | ||
@@ -236,8 +234,6 @@ if ($mailq eq "sendmail") { | |||
236 | ## shut off the alarm | 234 | ## shut off the alarm |
237 | alarm(0); | 235 | alarm(0); |
238 | 236 | ||
239 | |||
240 | |||
241 | ## now check the queue length(s) | 237 | ## now check the queue length(s) |
242 | 238 | ||
243 | if ($msg_q == 0) { | 239 | if ($msg_q == 0) { |
@@ -335,40 +331,38 @@ if ($mailq eq "sendmail") { | |||
335 | 331 | ||
336 | } # end of ($mailq eq "sendmail") | 332 | } # end of ($mailq eq "sendmail") |
337 | elsif ( $mailq eq "postfix" ) { | 333 | elsif ( $mailq eq "postfix" ) { |
338 | 334 | if( ! $utils::PATH_TO_MAILQ ) { | |
339 | ## open mailq | ||
340 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | ||
341 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ$mailq_args | " ) ) { | ||
342 | print "ERROR: could not open $utils::PATH_TO_MAILQ$mailq_args \n"; | ||
343 | exit $ERRORS{'UNKNOWN'}; | ||
344 | } | ||
345 | }elsif( defined $utils::PATH_TO_MAILQ){ | ||
346 | unless (-x $utils::PATH_TO_MAILQ) { | ||
347 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
348 | exit $ERRORS{'UNKNOWN'}; | ||
349 | } | ||
350 | } else { | ||
351 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | 335 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; |
352 | exit $ERRORS{'UNKNOWN'}; | 336 | exit $ERRORS{'UNKNOWN'}; |
353 | } | 337 | } |
354 | 338 | ||
339 | if ( ! -x $utils::PATH_TO_MAILQ) { | ||
340 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
341 | exit $ERRORS{'UNKNOWN'}; | ||
342 | } | ||
355 | 343 | ||
356 | @lines = reverse <MAILQ>; | 344 | ## open mailq |
345 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ$mailq_args | " ) ) { | ||
346 | print "ERROR: could not open $utils::PATH_TO_MAILQ$mailq_args \n"; | ||
347 | exit $ERRORS{'UNKNOWN'}; | ||
348 | } | ||
357 | 349 | ||
358 | # close qmail-qstat | 350 | @lines = reverse <MAILQ>; |
359 | close MAILQ; | ||
360 | 351 | ||
361 | if ( $? ) { | 352 | # close qmail-qstat |
362 | print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ$mailq_args",$/; | 353 | close MAILQ; |
363 | exit $ERRORS{CRITICAL}; | ||
364 | } | ||
365 | 354 | ||
366 | ## shut off the alarm | 355 | if ( $? ) { |
367 | alarm(0); | 356 | print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ$mailq_args",$/; |
357 | exit $ERRORS{CRITICAL}; | ||
358 | } | ||
368 | 359 | ||
369 | # check queue length | 360 | ## shut off the alarm |
370 | if ($lines[0]=~/Kbytes in (\d+)/) { | 361 | alarm(0); |
371 | $msg_q = $1 ; | 362 | |
363 | # check queue length | ||
364 | if ($lines[0]=~/Kbytes in (\d+)/) { | ||
365 | $msg_q = $1 ; | ||
372 | }elsif ($lines[0]=~/Mail queue is empty/) { | 366 | }elsif ($lines[0]=~/Mail queue is empty/) { |
373 | $msg_q = 0; | 367 | $msg_q = 0; |
374 | }else{ | 368 | }else{ |
@@ -417,20 +411,19 @@ elsif ( $mailq eq "postfix" ) { | |||
417 | } | 411 | } |
418 | } # end of ($mailq eq "postfix") | 412 | } # end of ($mailq eq "postfix") |
419 | elsif ( $mailq eq "qmail" ) { | 413 | elsif ( $mailq eq "qmail" ) { |
414 | if ( ! $utils::PATH_TO_QMAIL_QSTAT ) { | ||
415 | print "ERROR: \$utils::PATH_TO_QMAIL_QSTAT is not defined\n"; | ||
416 | exit $ERRORS{'UNKNOWN'}; | ||
417 | } | ||
418 | |||
419 | if ( ! -x $utils::PATH_TO_QMAIL_QSTAT) { | ||
420 | print "ERROR: $utils::PATH_TO_QMAIL_QSTAT is not executable by (uid $>:gid($)))\n"; | ||
421 | exit $ERRORS{'UNKNOWN'}; | ||
422 | } | ||
420 | 423 | ||
421 | # open qmail-qstat | 424 | # open qmail-qstat |
422 | if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) { | 425 | if (! open (MAILQ, "$sudo $utils::PATH_TO_QMAIL_QSTAT | " ) ) { |
423 | if (! open (MAILQ, "$sudo $utils::PATH_TO_QMAIL_QSTAT | " ) ) { | 426 | print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n"; |
424 | print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n"; | ||
425 | exit $ERRORS{'UNKNOWN'}; | ||
426 | } | ||
427 | }elsif( defined $utils::PATH_TO_QMAIL_QSTAT){ | ||
428 | unless (-x $utils::PATH_TO_QMAIL_QSTAT) { | ||
429 | print "ERROR: $utils::PATH_TO_QMAIL_QSTAT is not executable by (uid $>:gid($)))\n"; | ||
430 | exit $ERRORS{'UNKNOWN'}; | ||
431 | } | ||
432 | } else { | ||
433 | print "ERROR: \$utils::PATH_TO_QMAIL_QSTAT is not defined\n"; | ||
434 | exit $ERRORS{'UNKNOWN'}; | 427 | exit $ERRORS{'UNKNOWN'}; |
435 | } | 428 | } |
436 | 429 | ||
@@ -500,22 +493,22 @@ elsif ( $mailq eq "qmail" ) { | |||
500 | 493 | ||
501 | } # end of ($mailq eq "qmail") | 494 | } # end of ($mailq eq "qmail") |
502 | elsif ( $mailq eq "exim" ) { | 495 | elsif ( $mailq eq "exim" ) { |
503 | ## open mailq | 496 | if ( ! $utils::PATH_TO_MAILQ ) { |
504 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | ||
505 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { | ||
506 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
507 | exit $ERRORS{'UNKNOWN'}; | ||
508 | } | ||
509 | }elsif( defined $utils::PATH_TO_MAILQ){ | ||
510 | unless (-x $utils::PATH_TO_MAILQ) { | ||
511 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
512 | exit $ERRORS{'UNKNOWN'}; | ||
513 | } | ||
514 | } else { | ||
515 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | 497 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; |
516 | exit $ERRORS{'UNKNOWN'}; | 498 | exit $ERRORS{'UNKNOWN'}; |
517 | } | 499 | } |
518 | 500 | ||
501 | if ( ! -x $utils::PATH_TO_MAILQ) { | ||
502 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
503 | exit $ERRORS{'UNKNOWN'}; | ||
504 | } | ||
505 | |||
506 | ## open mailq | ||
507 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { | ||
508 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
509 | exit $ERRORS{'UNKNOWN'}; | ||
510 | } | ||
511 | |||
519 | while (<MAILQ>) { | 512 | while (<MAILQ>) { |
520 | #22m 1.7K 19aEEr-0007hx-Dy <> *** frozen *** | 513 | #22m 1.7K 19aEEr-0007hx-Dy <> *** frozen *** |
521 | #root@exlixams.glups.fr | 514 | #root@exlixams.glups.fr |
@@ -543,22 +536,22 @@ elsif ( $mailq eq "exim" ) { | |||
543 | } # end of ($mailq eq "exim") | 536 | } # end of ($mailq eq "exim") |
544 | 537 | ||
545 | elsif ( $mailq eq "nullmailer" ) { | 538 | elsif ( $mailq eq "nullmailer" ) { |
546 | ## open mailq | 539 | if( ! $utils::PATH_TO_MAILQ) { |
547 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | ||
548 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { | ||
549 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
550 | exit $ERRORS{'UNKNOWN'}; | ||
551 | } | ||
552 | }elsif( defined $utils::PATH_TO_MAILQ){ | ||
553 | unless (-x $utils::PATH_TO_MAILQ) { | ||
554 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
555 | exit $ERRORS{'UNKNOWN'}; | ||
556 | } | ||
557 | } else { | ||
558 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | 540 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; |
559 | exit $ERRORS{'UNKNOWN'}; | 541 | exit $ERRORS{'UNKNOWN'}; |
560 | } | 542 | } |
561 | 543 | ||
544 | if ( ! -x $utils::PATH_TO_MAILQ) { | ||
545 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
546 | exit $ERRORS{'UNKNOWN'}; | ||
547 | } | ||
548 | |||
549 | ## open mailq | ||
550 | if ( ! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { | ||
551 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
552 | exit $ERRORS{'UNKNOWN'}; | ||
553 | } | ||
554 | |||
562 | while (<MAILQ>) { | 555 | while (<MAILQ>) { |
563 | #2022-08-25 01:30:40 502 bytes from <user@example.com> | 556 | #2022-08-25 01:30:40 502 bytes from <user@example.com> |
564 | 557 | ||