#! /usr/bin/perl -w use strict; use Getopt::Long; use lib '/usr/lib/nagios/plugins'; use utils qw(%ERRORS &print_revision &support); my $config = { 'host' => undef, 'warn_jobs' => 50, 'crit_jobs' => 150, 'warn_hours' => 24, 'crit_hours' => 72, }; my $host; Getopt::Long::Configure('no_ignore_case'); GetOptions 'H=s' => \$host, 'host|h=s' => \$host, 'warn=s' => \$config->{warn_jobs}, 'crit=s' => \$config->{crit_jobs}, 'WARN=s' => \$config->{warn_hours}, 'CRIT=s' => \$config->{crit_hours}, 'help' => \&print_help; sub print_help { print<) { push @list, $_; } close $prg; return \@list; } unless ($host) { print "UUCP ERROR: -h missing\n"; exit $ERRORS{CRITICAL}; } my $list = uustat $host; unless (defined $list) { printf "UUCP CRITICAL - %s: Execution of uustat failed\n", $host; exit $ERRORS{CRITICAL}; } if (scalar @$list > $config->{warn_jobs}) { printf "UUCP WARNING - %s: %d jobs\n", $host, scalar @$list; exit $ERRORS{WARNING}; } if (scalar @$list > $config->{crit_jobs}) { printf "UUCP CRITICAL - %s: %d jobs\n", $host, scalar @$list; exit $ERRORS{CRITICAL}; } my $oldlist; $oldlist = uustat $host, $config->{warn_hours}; unless (defined $oldlist) { printf "UUCP WARNING - %s: Execution of uustat failed\n", $host; exit $ERRORS{WARNING}; } if (scalar @$oldlist > 0) { printf "UUCP WARNING - %s: %d jobs older than %d hours\n", $host, scalar @$list, scalar @$list, $config->{crit_hours}; exit $ERRORS{WARNING}; } $oldlist = uustat $host, $config->{crit_hours}; unless (defined $oldlist) { printf "UUCP WARNING - %s: Execution of uustat failed\n", $host; exit $ERRORS{WARNING}; } if (scalar @$oldlist > 0) { printf "UUCP CRITICAL - %s: %d jobs older than %d hours\n", $host, scalar @$list, $config->{crit_hours}; exit $ERRORS{CRITICAL}; } printf "UUCP OK - %s: %d jobs\n", $host, scalar @$list; exit $ERRORS{'OK'};