#!/bin/bash # Copyright (C) 2012 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. # # # Author : Michael Tate, Sys Admin, ESI # Purpose : Check number of DISABLED pound forwarders USAGE="check_pound_rotation (WARN if 1 brick, CRIT if 2 or more)" if [[ $1 == *help* ]]; then echo "Usage: $USAGE" exit 0 fi PCOUNT=`sudo poundctl -c /var/run/pound/poundctl.socket | grep -c DISABLED` PDETAIL=`sudo poundctl -c /var/run/pound/poundctl.socket | grep DISABLED |cut -d":" -f1|cut -c18-|sort|uniq` if [[ $1 == *help* ]]; then echo "Usage: $USAGE" else if [ $PCOUNT -gt 0 ]; then EXITSTATUS="WARN: $PCOUNT Services disabled; " EXITCODE=1 elif [ $PCOUNT -gt 2 ]; then EXITSTATUS="CRIT: $PCOUNT Services disabled; " EXITCODE=2 elif [ $PCOUNT -lt 1 ]; then EXITSTATUS="OK: $PCOUNT Services disabled." EXITCODE=0 fi fi echo -n $EXITSTATUS echo $PDETAIL exit $EXITCODE