monitors:smart

smartmon

Author mikadel
Compatibility Xymon 4.3
Requirements Linux, smartmontools
Download None
Last Update 2011-10-06

In conjunction with the smartmontools package this script monitors the S.M.A.R.T. status of your hard drives on Linux. This also works if your hard drives are “hidden” behind a raid controller.

Note: This currently only works for the first hard drive.

Client side

Create the following files in your xymon client directory:

monitoring script: <xymon-client-ext>/smart

monitoring config: <xymon-client-etc>/smart.conf

xymon monitor config: <xymon-client-etc>/clientlaunch.d/smart.cfg

Find your RAID crontroller at http://sourceforge.net/apps/trac/smartmontools/wiki/Supported_RAID-Controllers and change CONTROLLER@smart.conf accordingly.

Additionally you have to allow sudo for hobbit. Edit visudo and add this line:

hobbit ALL=NOPASSWD:/usr/sbin/smartctl

Server side

None.

Show Code ⇲

Hide Code ⇱

#!/bin/bash

COLOR="clear"
COLUMN="smart"
CONFIG="${HOBBITCLIENTHOME}/etc/smart.conf"
MSG="No S.M.A.R.T. device detected."
RAID=""
SMARTCTL="/usr/sbin/smartctl"
SUDO="/usr/bin/sudo"

# read config file
source $CONFIG

if [ -n "$CONTROLLER" ]; then
        RAID="-d $CONTROLLER,$COUNT"
fi
RESULT="Device:\n\t$DEVICE\n\nStatus:\n\n"


TMP=`$SUDO $SMARTCTL /dev/$DEVICE $RAID --all -X`
SMART=`echo "$TMP" | grep "Device supports SMART and is Enabled"`

if [ -n "$SMART" ]; then
        MSG="$TMP"
        COLOR="green"
        RESULT="$RESULT\t&green Device supports SMART and is Enabled\n"

        STATUS=`echo "$TMP" | grep "SMART Health Status: OK"`
        if [ -z "$STATUS" ]; then
                COLOR="red"
                RESULT="$RESULT&red SMART Health Status not OK\n"
        else
                RESULT="$RESULT\t&green SMART Health Status: OK\n"
        fi

        SELF=`echo "$TMP" | grep "Self Test returned without error"`
        if [ -z "$SELF" ]; then
                COLOR="red"
                RESULT="$RESULT&red Self Test returned with error\n"
        else
                RESULT="$RESULT\t&green Self Test returned without error\n"
        fi
fi

MSG=`echo -e "\n$RESULT\n\n$MSG\n"`

$BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date` $MSG"

Show Code ⇲

Hide Code ⇱

[smart]
	ENVFILE /etc/hobbit/hobbitclient.cfg
	CMD $HOBBITCLIENTHOME/ext/smart
	LOGFILE /var/log/hobbit/smart.log
	INTERVAL 5m

Show Code ⇲

Hide Code ⇱

# S.M.A.R.T. monitoring configuration
CONTROLLER="cciss"
COUNT=1
DEVICE="sda"

This currently only works for the first hard drive.

Enable monitoring for all hard drives.

  • 2011-10-06
    • Initial release
  • monitors/smart.txt
  • Last modified: 2011/10/10 15:08
  • by 127.0.0.1