equal
deleted
inserted
replaced
1 #! /usr/bin/perl -w |
1 #! /usr/bin/perl -w |
2 # $Id$ |
2 # $Id$ |
3 # $URL$ |
3 # $URL$ |
4 |
4 |
5 use strict; |
5 use strict; |
|
6 use warnings; |
|
7 |
6 use File::Basename; |
8 use File::Basename; |
7 use Getopt::Long; |
9 use Getopt::Long; |
|
10 use POSIX qw(:sys_wait_h); |
8 use lib "/usr/lib/nagios/plugins"; |
11 use lib "/usr/lib/nagios/plugins"; |
9 use utils qw (%ERRORS &print_revision &support); |
12 use utils qw (%ERRORS &print_revision &support); |
10 |
13 |
11 sub print_help(); |
14 sub print_help(); |
12 sub print_usage(); |
15 sub print_usage(); |
56 unless ( -x $opt_b ) { |
59 unless ( -x $opt_b ) { |
57 print "MAILQ CRITICAL: exipick not found or not executable - $opt_b\n"; |
60 print "MAILQ CRITICAL: exipick not found or not executable - $opt_b\n"; |
58 exit $ERRORS{"CRITICAL"}; |
61 exit $ERRORS{"CRITICAL"}; |
59 } |
62 } |
60 |
63 |
|
64 $SIG{CHLD} = sub { |
|
65 while (waitpid(-1, WNOHANG) > 0) {}; |
|
66 }; |
|
67 |
61 # check the mailq |
68 # check the mailq |
62 `$opt_b -o $opt_s -c` =~ /^(\d+).*/; |
69 die "Can't fork: $!" unless defined (my $pid = open(F, "-|")); |
63 $mailq = $1; |
70 if ($pid) { |
|
71 <F> =~ /^(\d+).*/; |
|
72 $mailq = $1; |
|
73 close F; |
|
74 } else { |
|
75 exec $opt_b, '-o', $opt_s, '-c', @ARGV |
|
76 or die "can't exec $opt_b: $!"; |
|
77 } |
64 |
78 |
65 SWITCH: { |
79 SWITCH: { |
66 $mailq < $opt_w and $result = "OK", last; |
80 $mailq < $opt_w and $result = "OK", last; |
67 $mailq >= $opt_c and $result = "CRITICAL", last; |
81 $mailq >= $opt_c and $result = "CRITICAL", last; |
68 $mailq >= $opt_w and $result = "WARNING", last; |
82 $mailq >= $opt_w and $result = "WARNING", last; |