-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_arcconf
executable file
·141 lines (121 loc) · 3.57 KB
/
check_arcconf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# Adaptec AAC-RAID plugin for Nagios
# Written by M.Koettenstorfer ([email protected])
# Modified by Henrik Hussfelt ([email protected])
# Last Modified: 2011-06-02
# Description:
#
# This plugin will check the status of a local
# Adaptec AAC-RAID. It will provide what type of errors that has ouccured
# count them and output an error row.
# Depending on user settings in -w and -c giving WARNING and CRITICAL
# message at different points
#
# where arcconf lives
RUNARCONF="/usr/StorMan/arcconf"
ARCONFLISTSTATE="$RUNARCONF GETLOGS 1 DEVICE tabular"
# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
if [ ! -x "$RUNARCONF" ]
then
echo "UNKNOWN: $ARCONFLISTSTATE not found or is not executable by the nagios user"
exitstatus=$STATE_UNKNOWN
exit $exitstatus
fi
PROGNAME=`basename $0`
print_usage() {
echo "Usage: $PROGNAME SOME OPTIONS>"
echo ""
echo "Notes:"
echo "-w: WARNING level for errors"
echo "-c: CRITICAL level for errors"
echo ""
}
print_help() {
print_usage
echo ""
echo "This plugin will check the howmany errors happend on Raid Controller."
echo ""
exit 0
}
check_error_count()
{
if [ "$allerrors" -ge "$critlevel" ]
then
MESSAGE="RAID CRITICAL, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors"
exitstatus=$STATE_CRITICAL
elif [ "$allerrors" -ge "$warnlevel" ]
then
MESSAGE="RAID WARNING, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors"
exitstatus=$STATE_WARNING
else
MESSAGE="RAID OK, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors"
exitstatus=$STATE_OK
fi
}
if [ $# -lt 4 ]; then
print_usage
exit $STATE_UNKNOWN
fi
exitstatus=$STATE_UNKNOWN #default
while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
-w)
warnlevel=$2
shift
;;
-c)
critlevel=$2
shift
;;
esac
shift
done
# Check arguments for validity
if [ $warnlevel -gt $critlevel ] # Do the warn/crit values make sense?
then
echo "CRITICAL value of $critlevel less than WARNING level of $warnlevel"
print_usage
exitstatus=$STATE_UNKNOWN
exit $exitstatus
elif [ -n $library ]
then
TMP=`mktemp numerrors.XXXXXX` # Create a tmpfile to store the full test result
HTMP=`mktemp hwerrors.XXXXXX` # Create a tmpfile to store the full test result
MTMP=`mktemp mediumerrors.XXXXXX` # Create a tmpfile to store the full test result
$ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep numParityErrors| awk '{print $3}' > $TMP
$ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep hwErrors | awk '{print $3}' > $HTMP
$ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep mediumErrors | awk '{print $3}' > $MTMP
numParityErrors=`a=$(cat $TMP) ; echo $a | tr ' ' '+'| bc`
hwErrors=`a=$(cat $HTMP) ; echo $a | tr ' ' '+'| bc`
mediumErrors=`a=$(cat $MTMP) ; echo $a | tr ' ' '+'| bc`
# Fix if error on empty non-integer strings
if [[ $numParityErrors != [0-9]* ]]; then
numParityErrors=`echo 0`;
fi;
if [[ $hwErrors != [0-9]* ]]; then
let hwErrors=`echo 0`;
fi;
if [[ $mediumErrors != [0-9]* ]]; then
let mediumErrors=`echo 0`;
fi;
allerrors=`echo "$numParityErrors + $hwErrors + $mediumErrors" | bc`
check_error_count
rm -rf $TMP
rm -rf $HTMP
rm -rf $MTMP
fi
echo $MESSAGE
exit $exitstatus