summaryrefslogtreecommitdiffstats
path: root/remote/modules/smartctl/data/opt/openslx
diff options
context:
space:
mode:
authorSimon Rettberg2014-01-13 14:11:28 +0100
committerSimon Rettberg2014-01-13 14:11:28 +0100
commitf853dc0f548ba86181e2c2682629b4d51d302efd (patch)
treeacf120952c8a3cdd28f07080e4da18657ead62a5 /remote/modules/smartctl/data/opt/openslx
parent[vmchooser] Refining iptables MASQUERADE rule to work around an issue where i... (diff)
parentupdate cups to work with ubuntu 13.10 (diff)
downloadtm-scripts-f853dc0f548ba86181e2c2682629b4d51d302efd.tar.gz
tm-scripts-f853dc0f548ba86181e2c2682629b4d51d302efd.tar.xz
tm-scripts-f853dc0f548ba86181e2c2682629b4d51d302efd.zip
Merge branch 'master' of dnbd3:openslx-ng/tm-scripts
Diffstat (limited to 'remote/modules/smartctl/data/opt/openslx')
-rwxr-xr-xremote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl16
1 files changed, 14 insertions, 2 deletions
diff --git a/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl b/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl
index 6025c962..6a798563 100755
--- a/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl
+++ b/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl
@@ -2,18 +2,30 @@
# Check Reallocated_Sector_Ct and Spin_Retry_Count of local disk(s)
+. /opt/openslx/config
+
+[ -z "$SLX_SMARTCTL_MIN_REALLOC" ] && SLX_SMARTCTL_MIN_REALLOC=0
+
FILE=$(mktemp)
for dev in /dev/sd?; do
- smartctl -A "$dev" -f "brief" > "$FILE" || continue # should we report devices where smartctl doesn't work?
+ smartctl -H -A -f "brief" "$dev" > "$FILE" || continue # should we report devices where smartctl doesn't work?
+ # parse
+ OVERALL=$(grep -o "test result: .*$" "$FILE" | cut -c 14-)
+ [ "x$OVERALL" = "xPASSED" ] && OVERALL=""
REALLOC=$(grep "^ *5 " "$FILE" | awk '{print $8}')
SPINRETRY_VAL=$(grep "^ *10 " "$FILE" | awk '{print $4}')
SPINRETRY_THR=$(grep "^ *10 " "$FILE" | awk '{print $6}')
- if [ -n "$REALLOC" ] && [ "$REALLOC" != "0" ]; then
+ # report if applicable
+ if [ -n "$OVERALL" ]; then
+ slxlog "smartctl-fail" "Failed HDD: $dev reports health as $OVERALL" "$FILE"
+ fi
+ if [ -n "$REALLOC" ] && [ "$REALLOC" -gt "$SLX_SMARTCTL_MIN_REALLOC" ]; then
slxlog "smartctl-realloc" "Failing HDD: $dev has $REALLOC reallocated sectors!" "$FILE"
fi
if [ -n "$SPINRETRY_VAL" ] && [ "$SPINRETRY_VAL" -le "$SPINRETRY_THR" ]; then
slxlog "smartctl-spinretry" "Failing HDD: $dev has bad spin retry count! ($SPINRETRY_VAL/$SPINRETRY_THR)" "$FILE"
fi
done
+sleep 2 # give slxlog a little time, as it's running async
rm -f -- "$FILE"