#!/bin/sh # Copyright (C) 2008-2010 Equinox Software, Inc. # # 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 : Look for excessive NOT CONNECTEDS in the osrfsys logs in the current hour USAGE="check_notconnected " if [[ $1 == *help* ]]; then echo "Usage: $USAGE" exit 0 fi ## GET/SET Variables ## CRITLIMIT=20 WARNLIMIT=12 # logfile path if [ -n "$1" ]; then LOGPATH="$1" else LOGPATH="/var/log/evergreen/prod" fi NCCOUNT=`grep -c "IS NOT CONNECTED TO THE NETWORK" $LOGPATH/$(date +%Y/%m/%d)/osrfsys.$(date +%H).log` if [ $NCCOUNT -ge $CRITLIMIT ]; then TOPSERVER=$(grep "IS NOT CONNECTED TO THE NETWORK" $LOGFILE | cut -d" " -f3 | sort | uniq -c | sort -nr | head -1) SVRMSG=" (Top server this hour: $TOPSERVER)" EXITSTATUS="CRIT" EXITCODE=2 elif [ $NCCOUNT -ge $WARNLIMIT ]; then TOPSERVER=$(grep "IS NOT CONNECTED TO THE NETWORK" $LOGFILE | cut -d" " -f3 | sort | uniq -c | sort -nr | head -1) SVRMSG=" (Top server this hour: $TOPSERVER)" EXITSTATUS="WARN" EXITCODE=1 elif [[ $NCCOUNT -lt $WARNLIMIT ]; then EXITSTATUS="OK" EXITCODE=0 SVRMSG="." else EXITSTATUS="WARN: An error has occurred $PREVTOT $PERIOD" EXITCODE=1 fi echo "$EXITSTATUS: $NCCOUNT NOT CONNECTEDs returned this hour$SVRMSG" exit $EXITCODE