#!/usr/bin/perl -w use strict; # $Id$ ## Nagios plugin to check the queue depth of a Schwartz database. use utils qw( %ERRORS $TIMEOUT ); use Getopt::Long qw( :config no_ignore_case ); use DBI; use constant QUEUE_CRITICAL => 100; use constant QUEUE_WARNING => 30; GetOptions( 'h|help!' => \my($help), 'v|verbose' => \my($verbose), 'dsn=s' => \my($dsn), 'user=s' => \my($user), 'password=s' => \my($pass), ); if ($help) { print "$0 --dsn --user --password "; exit $ERRORS{OK}; } unless ($dsn && $user) { print <connect($dsn, $user, $pass) or exit_with 'CRITICAL', "Can't connect to $dsn: $DBI::errstr"; my $inf = $dbh->selectrow_arrayref(<[0]) { exit_with 'CRITICAL', "Failed getting job count: " . $dbh->errstr; } if ($inf->[0] < QUEUE_WARNING) { exit_with 'OK'; } elsif ($inf->[0] < QUEUE_CRITICAL) { exit_with 'WARNING', "Schwartz queue depth is $inf->[0]"; } else { exit_with 'CRITICAL', "Schwartz queue depth is $inf->[0]"; }