#!/bin/bash # Copyright (C) 2008-2011 Equinox Software, Inc. # Written by Michael Tate # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Purpose : Count AT pending events USAGE="check_at_pending " if [[ $1 == *help* ]]; then echo "Usage: $USAGE" exit 0 fi ## GET/SET Variables ## # The values below are arbitrary, change them to match your environment. CTWARN=900000 # How many pending transactions to WARN at CTCRIT=1000000 # How many pending transactions to CRIT at # database name if [ -n "$1" ]; then dbname="$1" else dbname="evergreen" fi # database user name if [ -n "$2" ]; then dbuser="$1" else dbuser="evergreen" fi # port database runs on if [ -n "$3" ]; then dbport="$3" else dbport=5432 fi ## Execute Plugin ## # DB Query Count ATPENDING=`PGUSER=postgres psql -U $dbuser -d $dbname -p $dbport -c "select count(*) from action_trigger.event where state ='pending';"|sed -n '3'p` ## Return results ## if [[ $ATPENDING == "-00" ]]; then EXITSTATUS="OK: No AT events pending" EXITCODE=0 else if [ $ATPENDING -gt $CTCRIT ]; then EXITSTATUS="CRITICAL: $ATPENDING AT events pending" EXITCODE=2 elif [ $ATPENDING -gt $CTWARN ]; then EXITSTATUS="WARNING: $ATPENDING AT events pending" EXITCODE=1 else EXITSTATUS="OK: $ATPENDING AT events pending" EXITCODE=0 fi fi echo "$EXITSTATUS" exit $EXITCODE