diff options
author | Sebastian | 2016-04-25 12:01:08 +0200 |
---|---|---|
committer | Sebastian | 2016-04-25 12:01:08 +0200 |
commit | 5acda3eaeabae9045609539303a8c12c4ce401f1 (patch) | |
tree | 7e71975f8570b05aafe2ea6ec0e242a8912387bb /core/modules/smartctl | |
parent | initial commit (diff) | |
download | mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.gz mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.xz mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.zip |
merge with latest dev version
Diffstat (limited to 'core/modules/smartctl')
-rw-r--r-- | core/modules/smartctl/data/etc/cron.d/openslx-smartctl | 8 | ||||
l--------- | core/modules/smartctl/data/etc/systemd/system/basic.target.wants/smartctl.service | 1 | ||||
-rw-r--r-- | core/modules/smartctl/data/etc/systemd/system/smartctl.service | 8 | ||||
-rwxr-xr-x | core/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl | 33 | ||||
-rw-r--r-- | core/modules/smartctl/module.build | 13 | ||||
-rw-r--r-- | core/modules/smartctl/module.conf | 5 | ||||
-rw-r--r-- | core/modules/smartctl/module.conf.centos | 6 | ||||
-rw-r--r-- | core/modules/smartctl/module.conf.debian | 6 | ||||
-rw-r--r-- | core/modules/smartctl/module.conf.fedora | 6 | ||||
-rw-r--r-- | core/modules/smartctl/module.conf.opensuse | 6 | ||||
-rw-r--r-- | core/modules/smartctl/module.conf.ubuntu | 6 |
11 files changed, 98 insertions, 0 deletions
diff --git a/core/modules/smartctl/data/etc/cron.d/openslx-smartctl b/core/modules/smartctl/data/etc/cron.d/openslx-smartctl new file mode 100644 index 00000000..a895e8db --- /dev/null +++ b/core/modules/smartctl/data/etc/cron.d/openslx-smartctl @@ -0,0 +1,8 @@ +# Check smart values at night. If the machine gets shut down at night, +# this will not trigger, but we check it once on boot anyways. + +SHELL=/bin/ash +PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin + +4 4 * * * root /opt/openslx/scripts/systemd-smartctl + diff --git a/core/modules/smartctl/data/etc/systemd/system/basic.target.wants/smartctl.service b/core/modules/smartctl/data/etc/systemd/system/basic.target.wants/smartctl.service new file mode 120000 index 00000000..b0849c0c --- /dev/null +++ b/core/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/core/modules/smartctl/data/etc/systemd/system/smartctl.service b/core/modules/smartctl/data/etc/systemd/system/smartctl.service new file mode 100644 index 00000000..ab268cbc --- /dev/null +++ b/core/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/core/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl b/core/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl new file mode 100755 index 00000000..1eef0a23 --- /dev/null +++ b/core/modules/smartctl/data/opt/openslx/scripts/systemd-smartctl @@ -0,0 +1,33 @@ +#!/bin/ash + +# 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 +FILES= + +for dev in /dev/sd?; do + FILE=$(mktemp) + FILES="$FILES $FILE" + 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}') + # 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 +[ -n "$FILES" ] && rm -f -- $FILES # list, no "" + diff --git a/core/modules/smartctl/module.build b/core/modules/smartctl/module.build new file mode 100644 index 00000000..435a7b10 --- /dev/null +++ b/core/modules/smartctl/module.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/core/modules/smartctl/module.conf b/core/modules/smartctl/module.conf new file mode 100644 index 00000000..9ea1ed03 --- /dev/null +++ b/core/modules/smartctl/module.conf @@ -0,0 +1,5 @@ +REQUIRED_BINARIES=" + smartctl +" +REQUIRED_LIBRARIES="" +REQUIRED_DIRECTORIES="" diff --git a/core/modules/smartctl/module.conf.centos b/core/modules/smartctl/module.conf.centos new file mode 100644 index 00000000..d699f2f0 --- /dev/null +++ b/core/modules/smartctl/module.conf.centos @@ -0,0 +1,6 @@ +REQUIRED_CONTENT_PACKAGES=" + smartmontools +" +REQUIRED_INSTALLED_PACKAGES=" + smartmontools +" diff --git a/core/modules/smartctl/module.conf.debian b/core/modules/smartctl/module.conf.debian new file mode 100644 index 00000000..d699f2f0 --- /dev/null +++ b/core/modules/smartctl/module.conf.debian @@ -0,0 +1,6 @@ +REQUIRED_CONTENT_PACKAGES=" + smartmontools +" +REQUIRED_INSTALLED_PACKAGES=" + smartmontools +" diff --git a/core/modules/smartctl/module.conf.fedora b/core/modules/smartctl/module.conf.fedora new file mode 100644 index 00000000..d699f2f0 --- /dev/null +++ b/core/modules/smartctl/module.conf.fedora @@ -0,0 +1,6 @@ +REQUIRED_CONTENT_PACKAGES=" + smartmontools +" +REQUIRED_INSTALLED_PACKAGES=" + smartmontools +" diff --git a/core/modules/smartctl/module.conf.opensuse b/core/modules/smartctl/module.conf.opensuse new file mode 100644 index 00000000..d699f2f0 --- /dev/null +++ b/core/modules/smartctl/module.conf.opensuse @@ -0,0 +1,6 @@ +REQUIRED_CONTENT_PACKAGES=" + smartmontools +" +REQUIRED_INSTALLED_PACKAGES=" + smartmontools +" diff --git a/core/modules/smartctl/module.conf.ubuntu b/core/modules/smartctl/module.conf.ubuntu new file mode 100644 index 00000000..d699f2f0 --- /dev/null +++ b/core/modules/smartctl/module.conf.ubuntu @@ -0,0 +1,6 @@ +REQUIRED_CONTENT_PACKAGES=" + smartmontools +" +REQUIRED_INSTALLED_PACKAGES=" + smartmontools +" |