3 # Copyright (c) 2014 Joey Schulze <joey@infodrom.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
21 use lib '/usr/lib/nagios/plugins';
22 use utils qw(%ERRORS);
34 Getopt::Long::Configure('no_ignore_case');
37 'warn=s' => \$config->{warn_jobs},
38 'crit=s' => \$config->{crit_jobs},
39 'WARN=s' => \$config->{warn_hours},
40 'CRIT=s' => \$config->{crit_hours},
41 'help' => \&print_help;
56 my $cmd = sprintf('/usr/bin/uustat -s %s %s', $host,
57 $hours ? '-o ' . $hours : '');
59 open my $prg, '-|', $cmd || return;
70 print "UUCP ERROR: -h <hostname> missing\n";
71 exit $ERRORS{CRITICAL};
74 my $list = uustat $host;
76 unless (defined $list) {
77 printf "UUCP CRITICAL - %s: Execution of uustat failed\n", $host;
78 exit $ERRORS{CRITICAL};
81 if (scalar @$list > $config->{warn_jobs}) {
82 printf "UUCP WARNING - %s: %d jobs\n", $host, scalar @$list;
83 exit $ERRORS{WARNING};
86 if (scalar @$list > $config->{crit_jobs}) {
87 printf "UUCP CRITICAL - %s: %d jobs\n", $host, scalar @$list;
88 exit $ERRORS{CRITICAL};
92 $oldlist = uustat $host, $config->{warn_hours};
94 unless (defined $oldlist) {
95 printf "UUCP WARNING - %s: Execution of uustat failed\n", $host;
96 exit $ERRORS{WARNING};
99 if (scalar @$oldlist > 0) {
100 printf "UUCP WARNING - %s: %d jobs older than %d hours\n", $host, scalar @$list, scalar @$list, $config->{crit_hours};
101 exit $ERRORS{WARNING};
104 $oldlist = uustat $host, $config->{crit_hours};
106 unless (defined $oldlist) {
107 printf "UUCP WARNING - %s: Execution of uustat failed\n", $host;
108 exit $ERRORS{WARNING};
111 if (scalar @$oldlist > 0) {
112 printf "UUCP CRITICAL - %s: %d jobs older than %d hours\n", $host, scalar @$list, $config->{crit_hours};
113 exit $ERRORS{CRITICAL};
116 printf "UUCP OK - %s: %d jobs\n", $host, scalar @$list;