Created
October 7, 2015 00:48
-
-
Save fukawi2/501798887213e3f27ddf to your computer and use it in GitHub Desktop.
Monitor mdadm array on desktop PC
This file contains hidden or 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
#!/bin/bash | |
set -e | |
set -u | |
declare -r ARRAY_DEV="${1-}" | |
if [[ -z "$ARRAY_DEV" ]] ; then | |
zenity --info --text "Usage: $0 [array_device]" | |
exit -1 | |
fi | |
declare -r array_status_file="/sys/block/$ARRAY_DEV/md/degraded" | |
if [[ ! -e "$array_status_file" ]] ; then | |
zenity --info --text "Device does not exist? $ARRAY_DEV" | |
exit -1 | |
fi | |
array_status="$(cat /sys/block/$ARRAY_DEV/md/degraded)" | |
array_state="$(cat /sys/block/$ARRAY_DEV/md/array_state)" | |
logger -t 'monitor-mdadm' "Array $ARRAY_DEV is in state: $array_state (Degraded status: $array_status)" | |
if [[ "$array_status" -ne '0' ]] ; then | |
zenity --warning --text "Array $ARRAY_DEV is degraded: $array_state" | |
fi | |
exit $array_status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment