Last active
August 14, 2024 01:48
-
-
Save marshki/a9ed47527d8c2a44456402a05884c429 to your computer and use it in GitHub Desktop.
Bash check for Offlne (Onln=Online|Offln=Offline) disk using 'storecli' and 'awk' on MegaRAID controller cards.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# disk_check | |
# | |
# Emit warning if disk(s) on RAID controller cards found to be in "Offln" state | |
# storcli reference: https://docs.broadcom.com/doc/12352476 | |
# | |
# Author: M. Krinitz <mjk235 [at] nyu [dot] edu> | |
# Date: 09-Aug-2024 | |
# License: MIT | |
# | |
storcli="/opt/MegaRAID/storcli/storcli64" | |
date="$(date +'%b %d %Y %X')" | |
host="$(hostname)" | |
# awk output of storcli command: | |
# Find line(s) containing: `DG Drive LIST :` | |
# then continue processing until lines containing: `Total Drive Count` are found | |
# If third column mathces `Offln`, exit and emit warning | |
if $storcli /call/dall show all | awk '/DG Drive LIST :/,/Total Drive Count/ \ | |
{ if ($3 == "Offln") exit 0 } END { exit 1 }'; then | |
printf "%s\n" "Offline disk(s) found on: $host@$date." \ | |
"Replace the blinking red disk(s) in the front and/or back of the array." | |
else | |
printf "%s\n" "No offline disk(s) found on: $host@$date. Exiting." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment