-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhpacucli-check.sh
229 lines (210 loc) · 8.61 KB
/
hpacucli-check.sh
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/bin/bash
###
# FILE: hpacucli-check.sh (03-Dec-2013)
# LICENSE: GNU/GPL v3.0
# AUTHOR: Olaf Reitmaier Veracierta <[email protected]>
# USAGE: Check the status of the logical drives on a HP Server
# with ssacli (HP Array Configuration Utility Client)
# installed, syslog and send an email with errors.
##
SSACLI=/usr/sbin/ssacli
SSACLI_TMP=/tmp/ssacli.log
ERROR_FOUND=false
MAIL=destination_email_address_here
# Debugging?, just pass debug as first parameter.
if [ -z "$1" ]
then
DEBUG=0
elif [ "$1" == "debug" ]
then
DEBUG=1
fi
###
# SUPPORT COMMUNICATION - CUSTOMER ADVISORY - Document ID: c03676138 - Version: 1
# http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/kb/docDisplay/?sp4ts.oid=3924066&spf_p.tpst=kbDocDisplay&spf_p.prp_kbDocDisplay=wsrp-navigationalState%3DdocId%253Demr_na-c03676138-1%257CdocLocale%253D%257CcalledBy%253D&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken
# ADVISORY: Linux - HP Array Configuration Utility CLI for Linux (Hpacucli) Version 9.00 (Or Later) Is Delayed in Responding if Storage That Is Not Connected to Local Smart Array Controller Is Configured With Multiple LUNs
# DESCRIPTION: There may be a delay starting the HP Array Configuration Utility CLI for Linux (ssacli) Version 9.00 (or later) on an HP ProLiant server configured to detect multiple LUNs connected via Fibre or iSCSI storage. In addition, there may be times that certain commands will delay in operating. This occurs because functionality was added to the ACU to discover HP branded Solid State Drives (SSD) that are not connected to the HP Smart Array controllers.
# SCOPE: Any HP ProLiant server running the HP Array Configuration Utility CLI for Linux (ssacli) Version 9.00 (or later) configured to detect multiple LUNs connected via Fibre or iSCSI storage.
# RESOLUTION : To prevent the delay from occurring when accessing local storage, type the following command:
# export INFOMGR_BYPASS_NONSA=1
# To re-enable the feature non-smart array device scanning, type the following command.
# export -n INFOMGR_BYPASS_NONSA
# Or use hpssacli version 2.0-23.0 (or later) which is the purpose of this updated script.
###########################################################################################
# HPE Smart Storage Administrator (HPE SSA) CLI for Linux 64-bits
# The HPE Smart Storage Administrator CLI (HPE SSACLI) is a commandline-based disk configuration
# program that helps you configure, manage, diagnose, and monitor HPE ProLiant Smart Array Controllers
# and now other storage devices as well, such as host bus adapters (HBAs), HPE Storage controllers,
# and future devices such as SCSI Express drives, and SAS switch devices. HPE SSACLI replaces
# the existing HP Array Configuration CLI Utility, or ACUCLI, with an updated design and will deliver
# new features and functionality for various Smart Storage initiatives as they come online.
# HPE Smart Array Advanced Pack 1.0 and 2.0 features are now part of the baseline features of HPE SSACLI,
# with the appropriate firmware. HPE SSACLI will allow you to configure and manage your storage as before,
# but now with additional features, abilities, and supported devices. Existing ACUCLI scripts should only
# need to make minimal changes such as calling the appropriate binary or executable in order to maintain
# compatibility. HPE SSASCRIPTING - Scripting can be performed in offline or online environments.
# The HPE SSA Scripting application has 2 scripting modes – Capture and Input.
############################################################################################
# export INFOMGR_BYPASS_NONSA=1 // not required anymore using ssacli
##
# Clean temp files
function deleteTmpFiles
{
rm -f $FILE_DISK
rm -f $FILE_DRIVE
rm -f $FILE_ARRAY
rm -f $FILE_ARRAY_STATUS
rm -f $FILE_SLOT
rm -f $FILE_SLOT_STATUS
rm -f $FILE_EMAIL
}
# Logging
function doLog
{
# doLog "$slot" "$msg" "level" $DEBUG
slot=$1
msg=$2
level=$3
debug=$4
if [ "$level" == "error" ] || [ "$level" == "alert" ] || [ "$debug" == "1" ]
then
ERROR_FOUND=true
fi
logger -p syslog.$level -t ssacli "$msg"
echo -e "$msg \
" >> $FILE_EMAIL
#if [ "$level" == "error" ] || [ "$level" == "alert" ]
#then
# $SSACLI ctrl slot=$slot show config detail
# ERROR=1
#fi
}
SERVICE="ssacli"
if pgrep -x "$SERVICE" >/dev/null
then
msg="[ERROR] ssacli is already running, so will not run again"
echo $msg
logger -p syslog.info -t ssacli "$msg"
deleteTmpFiles
exit 1
fi
FILE_DATE=$(date "+%Y-%m-%d-%I_%M")
FILE_SLOT=/tmp/ssacli_${FILE_DATE}_slot.txt
FILE_SLOT_STATUS=/tmp/ssacli_${FILE_DATE}_slot_status.txt
FILE_ARRAY=/tmp/ssacli_${FILE_DATE}_array.txt
FILE_ARRAY_STATUS=/tmp/ssacli_${FILE_DATE}_array_status.txt
FILE_DRIVE=/tmp/ssacli_${FILE_DATE}_drive.txt
FILE_DISK=/tmp/ssacli_${FILE_DATE}_disk.txt
FILE_EMAIL=/tmp/ssacli_${FILE_DATE}_email.txt
# Controllers (Slots) Status
ERROR_NOSLOT=1
$SSACLI ctrl all show | grep "Slot " > $FILE_SLOT
while read line1
do
ERROR_NOSLOT=0
slot=`expr match "$line1" '.*Slot \([0-9]\).*'`
# Controller (Slot) Status
$SSACLI ctrl slot=$slot show status | grep "Status" | grep -v "Not Configured" > $FILE_SLOT_STATUS
while read line2
do
if echo "$line2" | grep "OK" > /dev/null
then
msg="[OK] RAID controller slot $slot -> $line2"
doLog "$slot" "$msg" "info" $DEBUG
else
msg="[ERROR] RAID controller slot $slot -> $line2"
doLog "$slot" "$msg" "error" $DEBUG
fi
done < $FILE_SLOT_STATUS
# Arrays Status
$SSACLI ctrl slot=$slot array all show | grep array > $FILE_ARRAY
while read line2
do
array=`expr match "$line2" '.*array \([a-Z]\).*'`
# Array Status
ERROR_NOARRAY=1
$SSACLI ctrl slot=$slot array $array show status | grep array > $FILE_ARRAY_STATUS
while read line3
do
ERROR_NOARRAY=0
if echo "$line3" | grep "OK" > /dev/null
then
msg="[OK] RAID controller slot $slot array $array -> $line3"
doLog "$slot" "$msg" "info" $DEBUG
else
msg="[ERROR] RAID controller slot $slot array $array -> $line3"
doLog "$slot" "$msg" "error" $DEBUG
fi
done < $FILE_ARRAY_STATUS
if [ $ERROR_NOARRAY -eq 1 ]
then
msg="[WARN] No array error on RAID controller slot #$slot"
doLog "$slot" "$msg" "warning" $DEBUG
fi
# Physical Drive (Disk) Status
ERROR_NODISK=1
$SSACLI ctrl slot=$slot physicaldrive all show | grep physicaldrive > $FILE_DISK
while read line4
do
ERROR_NODISK=0
physicaldrive=`expr match "$line4" '.*physicaldrive \(.*\:.*\:.*\) ('`
if [ `$SSACLI ctrl slot=$slot physicaldrive $physicaldrive show | grep "Status: OK" | wc -l` -eq 0 ]
then
msg="[ERROR] RAID controller slot #$slot physicaldrive $physicaldrive -> $line4"
doLog "$slot" "$msg" "error" $DEBUG
else
msg="[OK] RAID controller slot #$slot physicaldrive $physicaldrive -> $line4"
doLog "$slot" "$msg" "info" $DEBUG
fi
done < $FILE_DISK
if [ $ERROR_NODISK -eq 1 ]
then
msg="[WARN] No physical drive (disk) error on RAID controller slot #$slot"
doLog "$slot" "$msg" "warning" $DEBUG
fi
# Logical Drives Status
ERROR_NODRIVE=1
$SSACLI ctrl slot=$slot array $array logicaldrive all show | grep logicaldrive > $FILE_DRIVE
while read line4
do
ERROR_NODRIVE=0
logicaldrive=`expr match "$line4" '.*logicaldrive \([0-9]\).*'`
if [ `$SSACLI ctrl slot=$slot array $array logicaldrive $logicaldrive show | grep "Status: OK" | wc -l` -eq 0 ]
then
msg="[ERROR] RAID controller slot #$slot array $array drive #$logicaldrive -> $line4"
doLog "$slot" "$msg" "error" $DEBUG
else
msg="[OK] RAID controller slot #$slot array $array drive #$logicaldrive -> $line4"
doLog "$slot" "$msg" "info" $DEBUG
fi
done < $FILE_DRIVE
if [ $ERROR_NODRIVE -eq 1 ]
then
msg="[WARN] No logical drive error on RAID controller slot #$slot"
doLog "$slot" "$msg" "warning" $DEBUG
fi
# Array but no physical or logical driver detected is an error
if [ $ERROR_NOARRAY -eq 0 ]
then
if [ $ERROR_NODRIVE -eq 1 ] || [ $ERROR_NODISK -eq 1 ]
then
msg="[ERROR] RAID controller (slot) $slot array $array has no logical or physical drives"
doLog "$slot" "$msg" "alert" $DEBUG
fi
fi
done < $FILE_ARRAY
done < $FILE_SLOT
if [ $ERROR_NOSLOT -eq 1 ]
then
msg="[ERROR] No RAID controller (slot) detected" | mail -s "RAID Report : No Raid Controller found on `hostname`" $MAIL
doLog "$slot" "$msg" "alert" $DEBUG
fi
if $ERROR_FOUND
then
$SSACLI ctrl all show config detail >> $FILE_EMAIL
echo "$(cat $FILE_EMAIL)" | mail -s "RAID Report : ERRORS detected on `hostname`" $MAIL
else
$SSACLI ctrl all show config detail >> $FILE_EMAIL
echo "$(cat $FILE_EMAIL)" | mail -s "RAID Report : OK on `hostname`" $MAIL
fi
deleteTmpFiles