forked from loiccattani/Check-RAID
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-raid
More file actions
executable file
·22 lines (19 loc) · 915 Bytes
/
check-raid
File metadata and controls
executable file
·22 lines (19 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
# This script checks for any degraded/offline/failed/whatever software
# RAIDs, and if any are found emails a note to an admin. To use it,
# replace the ADMIN_EMAIL value with your own email address, drop it in
# /etc/periodic/daily, and change the owner to root. This'll make it
# run its check every morning at 3:15am.
#
# Warning: this script doesn't check anything other than software RAIDs
# built with the Apple (i.e. Disk Utility) RAID tools. It does not check
# any hardware RAIDs (including Apple's RAID card), or even any third-party
# software RAIDs. If "diskutil listraid" doesn't list it, it's not going
# to be checked.
#
ADMIN_EMAIL="user@example.com"
echo "Checking software RAID"
if diskutil appleRAID list | grep "^Status:" | grep -qv "Online$"; then
echo "RAID problem detected!"
diskutil appleRAID list | mail -s "RAID problem detected on $(hostname)" "$ADMIN_EMAIL"
fi