diff options
author | Simon Rettberg | 2013-12-20 00:45:35 +0100 |
---|---|---|
committer | Simon Rettberg | 2013-12-20 00:45:35 +0100 |
commit | 48f1e22f55118914fc0f045c12a2b1cdf103dff5 (patch) | |
tree | 1da12669d15bf2e44f60a50507c7150419729e58 | |
parent | [pam-freiburg] Try harder to get machine ticket, continue mounting if there's... (diff) | |
download | tm-scripts-48f1e22f55118914fc0f045c12a2b1cdf103dff5.tar.gz tm-scripts-48f1e22f55118914fc0f045c12a2b1cdf103dff5.tar.xz tm-scripts-48f1e22f55118914fc0f045c12a2b1cdf103dff5.zip |
[smartctl] New module: smartctl - Will currently check reallocated sectors and spin retry count - could be extended, but those seem to be the best indicators according to $SEARCH_ENGINE
7 files changed, 53 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" + diff --git a/remote/modules/smartctl/smartctl.build b/remote/modules/smartctl/smartctl.build new file mode 100644 index 00000000..435a7b10 --- /dev/null +++ b/remote/modules/smartctl/smartctl.build @@ -0,0 +1,13 @@ +fetch_source() { + : +} + +build() { + COPYLIST="list_dpkg_output" + list_packet_files > "$COPYLIST" + tarcopy "$(cat "${COPYLIST}" | sort -u)" "${MODULE_BUILD_DIR}" +} + +post_copy() { + : +} diff --git a/remote/modules/smartctl/smartctl.conf b/remote/modules/smartctl/smartctl.conf new file mode 100644 index 00000000..9ea1ed03 --- /dev/null +++ b/remote/modules/smartctl/smartctl.conf @@ -0,0 +1,5 @@ +REQUIRED_BINARIES=" + smartctl +" +REQUIRED_LIBRARIES="" +REQUIRED_DIRECTORIES="" diff --git a/remote/modules/smartctl/smartctl.conf.ubuntu b/remote/modules/smartctl/smartctl.conf.ubuntu new file mode 100644 index 00000000..d699f2f0 --- /dev/null +++ b/remote/modules/smartctl/smartctl.conf.ubuntu @@ -0,0 +1,6 @@ +REQUIRED_CONTENT_PACKAGES=" + smartmontools +" +REQUIRED_INSTALLED_PACKAGES=" + smartmontools +" diff --git a/remote/targets/stage32/smartctl b/remote/targets/stage32/smartctl new file mode 120000 index 00000000..3a48434f --- /dev/null +++ b/remote/targets/stage32/smartctl @@ -0,0 +1 @@ +../../modules/smartctl
\ No newline at end of file |