5 use lib '/usr/lib/nagios/plugins';
6 use utils qw(%ERRORS &print_revision &support);
18 Getopt::Long::Configure('no_ignore_case');
19 GetOptions 'H=s' => \$host,
21 'warn=s' => \$config->{warn_jobs},
22 'crit=s' => \$config->{crit_jobs},
23 'WARN=s' => \$config->{warn_hours},
24 'CRIT=s' => \$config->{crit_hours},
25 'help' => \&print_help;
40 my $cmd = sprintf('/usr/bin/uustat -s %s %s', $host,
41 $hours ? '-o ' . $hours : '');
43 open my $prg, '|-', $cmd || return;
54 print "UUCP ERROR: -h <hostname> missing\n";
55 exit $ERRORS{CRITICAL};
58 my $list = uustat $host;
60 unless (defined $list) {
61 printf "UUCP CRITICAL - %s: Execution of uustat failed\n", $host;
62 exit $ERRORS{CRITICAL};
65 if (scalar @$list > $config->{warn_jobs}) {
66 printf "UUCP WARNING - %s: %d jobs\n", $host, scalar @$list;
67 exit $ERRORS{WARNING};
70 if (scalar @$list > $config->{crit_jobs}) {
71 printf "UUCP CRITICAL - %s: %d jobs\n", $host, scalar @$list;
72 exit $ERRORS{CRITICAL};
76 $oldlist = uustat $host, $config->{warn_hours};
78 unless (defined $oldlist) {
79 printf "UUCP WARNING - %s: Execution of uustat failed\n", $host;
80 exit $ERRORS{WARNING};
83 if (scalar @$oldlist > 0) {
84 printf "UUCP WARNING - %s: %d jobs older than %d hours\n", $host, scalar @$list, scalar @$list, $config->{crit_hours};
85 exit $ERRORS{WARNING};
88 $oldlist = uustat $host, $config->{crit_hours};
90 unless (defined $oldlist) {
91 printf "UUCP WARNING - %s: Execution of uustat failed\n", $host;
92 exit $ERRORS{WARNING};
95 if (scalar @$oldlist > 0) {
96 printf "UUCP CRITICAL - %s: %d jobs older than %d hours\n", $host, scalar @$list, $config->{crit_hours};
97 exit $ERRORS{CRITICAL};
100 printf "UUCP OK - %s: %d jobs\n", $host, scalar @$list;