From d6ef25c95c399af690bdfd7ce0af4e40a91b5147 Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Mon, 28 Apr 2014 20:53:40 +0200 Subject: [PATCH 1/1] New UUCP queue check --- check_uucp | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 check_uucp diff --git a/check_uucp b/check_uucp new file mode 100755 index 0000000..bf8ca52 --- /dev/null +++ b/check_uucp @@ -0,0 +1,101 @@ +#! /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'}; -- 2.20.1