diff options
| author | Jonathan Bauer | 2013-12-20 17:47:01 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2013-12-20 17:47:01 +0100 |
| commit | 808559e1cad1747825984174248f4fdf5803ae8e (patch) | |
| tree | 6a69f5c4cfffcf9400a15f684d9658c67aaba9ff /remote/modules/smartctl/data | |
| parent | [rootfs-stage32] added 'getent' to stage32 (diff) | |
| parent | Merge branch 'master' of dnbd3:openslx-ng/tm-scripts (diff) | |
| download | tm-scripts-808559e1cad1747825984174248f4fdf5803ae8e.tar.gz tm-scripts-808559e1cad1747825984174248f4fdf5803ae8e.tar.xz tm-scripts-808559e1cad1747825984174248f4fdf5803ae8e.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote/modules/smartctl/data')
3 files changed, 28 insertions, 0 deletions
diff --git a/remote/modules/smartctl/data/etc/systemd/system/basic.target.wants/smartctl.service b/remote/modules/smartctl/data/etc/systemd/system/basic.target.wants/smartctl.service new file mode 120000 index 00000000..b0849c0c --- /dev/null +++ b/remote/modules/smartctl/data/etc/systemd/system/basic.target.wants/smartctl.service @@ -0,0 +1 @@ +../smartctl.service
\ No newline at end of file diff --git a/remote/modules/smartctl/data/etc/systemd/system/smartctl.service b/remote/modules/smartctl/data/etc/systemd/system/smartctl.service new file mode 100644 index 00000000..ab268cbc --- /dev/null +++ b/remote/modules/smartctl/data/etc/systemd/system/smartctl.service @@ -0,0 +1,8 @@ +[Unit] +Description=Check HDD health status + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/opt/openslx/scripts/systemd-smartctl + diff --git a/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl b/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl new file mode 100755 index 00000000..6025c962 --- /dev/null +++ b/remote/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl @@ -0,0 +1,19 @@ +#!/bin/ash + +# Check Reallocated_Sector_Ct and Spin_Retry_Count of local disk(s) + +FILE=$(mktemp) +for dev in /dev/sd?; do + smartctl -A "$dev" -f "brief" > "$FILE" || continue # should we report devices where smartctl doesn't work? + 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 + 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 +rm -f -- "$FILE" + |
