Last active
December 17, 2024 20:06
-
-
Save peci1/9ca0cd57d0ecc2c3a6cd4446207d213d to your computer and use it in GitHub Desktop.
A script for Turris Omnia that checks the status of a JMicron JMS56x RAID controller and sends a notification if something's wrong.
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
#!/bin/bash | |
# Based on the script from https://forum.odroid.com/viewtopic.php?t=29298 | |
# Changes to that script are released under BSD license (c) Martin Pecka, 2019. | |
# raidmgr_static can be downloaded here: https://wiki.odroid.com/_media/accessory/add-on_boards/xu4_cloudshell2/raidmgr_static_cloudshell2.zip | |
RAID_MANAGER="/usr/bin/raidmgr_static" | |
STATUS="$(echo -e "SR C0\nEX\n" | $RAID_MANAGER)" | |
logger -t raid -p notice "${STATUS}" | |
RAID_STATUS="$(echo "${STATUS}" | grep RaidStatus | awk '{ print $NF }')" | |
echo "The current JMicron RAID controller status is: ${RAID_STATUS}" | |
##Possible RAID STATES | |
##Broken | |
##Degrade | |
##Rebuilding | |
##Normal | |
case "${RAID_STATUS}" in | |
Degrade) | |
logger -t raid -p err "RAID status is Degrade" | |
create_notification -s error "Your RAID is in a DEGRADED STATE! It is recommended that an investigation and repair or replacement of the failing drive be done as soon as possible. Use ${RAID_MANAGER} to determine which drive has failed." | |
;; | |
Broken) | |
logger -t raid -p err "RAID status is Broken" | |
create_notification -s error "Your RAID is in a BROKEN STATE! It is recommended that an investigation and repair be done as soon as possible." | |
;; | |
Rebuilding) | |
percentage="$(echo -e "GR C0 R0\nEX\n" | "${RAID_MANAGER}" | grep -o "rebuild.*")" | |
logger -t raid -p warn "RAID status is Rebuilding (${percentage})" | |
create_notification -s news "Your RAID is currently rebuilding (${percentage})." | |
;; | |
Normal) | |
logger -t raid -p info "RAID status is Normal" | |
;; | |
*) | |
logger -t raid -p err "RAID status is unknown" | |
create_notification -s error "Hmm, Not sure what's going on with the RAID. Your RAID status is unknown. This isn't necessarily a bad thing, it just means we couldn't grab the status." | |
;; | |
esac | |
DISK_TEMPS="$(echo -e "SM C0 D0\nSM C0 D1\nEX\n" | "${RAID_MANAGER}" | grep "^ 190" | awk '{print $2}' | tr "\n" ", " | head -c-1)" | |
logger -t raid -p info "Disk temperatures are ${DISK_TEMPS}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment