]> git.evergreen-ils.org Git - contrib/equinox.git/blob - monitoring/nagios/check_notconnected
errant line sending a copy of the row
[contrib/equinox.git] / monitoring / nagios / check_notconnected
1 #!/bin/sh\r
2 # Copyright (C) 2008-2010  Equinox Software, Inc.\r
3 #\r
4 # This program is free software; you can redistribute it and/or\r
5 # modify it under the terms of the GNU General Public License\r
6 # as published by the Free Software Foundation; either version 2\r
7 # of the License, or (at your option) any later version.\r
8 #\r
9 # This program is distributed in the hope that it will be useful,\r
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12 # GNU General Public License for more details.\r
13 #\r
14 #\r
15 # Author       : Michael Tate, Sys Admin, ESI\r
16 # Purpose      : Look for excessive NOT CONNECTEDS in the osrfsys logs in the current hour\r
17 USAGE="check_notconnected <logpath (default to /var/log/evergreen/prod/, assumes central logging)>"\r
18 if [[ $1 == *help* ]]; then\r
19   echo "Usage: $USAGE"\r
20   exit 0\r
21 fi\r
22 \r
23 ## GET/SET Variables ##\r
24 CRITLIMIT=20\r
25 WARNLIMIT=12\r
26 \r
27 # logfile path\r
28 if [ -n "$1" ]; then\r
29   LOGPATH="$1"\r
30 else\r
31   LOGPATH="/var/log/evergreen/prod"\r
32 fi\r
33 \r
34 NCCOUNT=`grep -c "IS NOT CONNECTED TO THE NETWORK" $LOGPATH/$(date +%Y/%m/%d)/osrfsys.$(date +%H).log`\r
35 if [ $NCCOUNT -ge $CRITLIMIT ]; then\r
36    TOPSERVER=$(grep "IS NOT CONNECTED TO THE NETWORK" $LOGFILE | cut -d" " -f3 | sort | uniq -c | sort -nr | head -1)\r
37    SVRMSG=" (Top server this hour: $TOPSERVER)"\r
38    EXITSTATUS="CRIT"\r
39    EXITCODE=2\r
40 elif [ $NCCOUNT -ge $WARNLIMIT ]; then\r
41    TOPSERVER=$(grep "IS NOT CONNECTED TO THE NETWORK" $LOGFILE | cut -d" " -f3 | sort | uniq -c | sort -nr | head -1)\r
42    SVRMSG=" (Top server this hour: $TOPSERVER)"\r
43    EXITSTATUS="WARN"\r
44    EXITCODE=1\r
45 elif [[ $NCCOUNT -lt $WARNLIMIT ]; then\r
46    EXITSTATUS="OK"\r
47    EXITCODE=0\r
48    SVRMSG="."\r
49 else\r
50    EXITSTATUS="WARN: An error has occurred $PREVTOT $PERIOD"\r
51    EXITCODE=1\r
52 fi\r
53 \r
54 echo "$EXITSTATUS: $NCCOUNT NOT CONNECTEDs returned this hour$SVRMSG"\r
55 exit $EXITCODE\r
56 \r
57 \r