xymon-ext-scripts

Check-in [16c227a4e0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Only issue one smartctl command per drive Also fail if there are any reallocated sectors
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 16c227a4e0206a0f15899d9255eb989d3a88a6999878cfc7f0c3f57c47358413
User & Date: feld@feld.me 2015-01-29 13:53:45
Context
2015-01-29
13:57
formatting check-in: 622bef9208 user: feld@feld.me tags: master, trunk
13:53
Only issue one smartctl command per drive Also fail if there are any reallocated sectors check-in: 16c227a4e0 user: feld@feld.me tags: master, trunk
2015-01-28
17:50
filter out cdrom devices check-in: 9c33e94924 user: feld@feld.me tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to smart.sh.

44
45
46
47
48
49
50
51
52
53






54
55
56
57
58
59
60
61
62
63
64
65
66
67

# Xymon doesn't have /usr/local in PATH
PATH=${PATH}:/usr/local/bin:/usr/local/sbin

COLUMN=smart

MSG=$(for i in $(sysctl -n kern.disks | tr ' ' '\n' | sort | egrep -v '^cd'); do
	OUTPUT=$(sudo smartctl -f brief -H /dev/${i});
	SERIAL=$(sudo smartctl -i /dev/${i} | grep Serial | awk '{print $3}')
	MODEL=$(sudo smartctl -i /dev/${i} | grep "Device Model" | awk '{print $3,$4}')







        case "${OUTPUT}" in
                *PASSED)
			echo "&green ${i} PASSED [ Serial:${SERIAL} Model:${MODEL} ]"
                        ;;
		*)
			echo "&red ${i} FAILED [ Serial:${SERIAL} Model:${MODEL} ]"
	esac
done)

STATUS="$(hostname) SMART health status"

if (echo ${MSG} | grep -q FAILED); then
	COLOR=red







|
|
|
>
>
>
>
>
>

|

|


|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

# Xymon doesn't have /usr/local in PATH
PATH=${PATH}:/usr/local/bin:/usr/local/sbin

COLUMN=smart

MSG=$(for i in $(sysctl -n kern.disks | tr ' ' '\n' | sort | egrep -v '^cd'); do
	OUTPUT=$(sudo smartctl -a /dev/${i});
	SERIAL=$(echo "${OUTPUT}" | grep Serial | awk '{print $3}')
	MODEL=$(echo "${OUTPUT}" | grep "Device Model" | awk '{print $3,$4}')
	REALLOCATED=$(echo "${OUTPUT}" | grep Reallocated_Sector | awk '{print $10}')
	if [ ${REALLOCATED} -gt 0 ] ; then
		HEALTH="FAILED"
	else
	HEALTH=$(echo "${OUTPUT}" | grep "overall-health")
	fi

        case "${HEALTH}" in
                *PASSED)
			echo "&green ${i} PASSED [ Serial:${SERIAL} Model:${MODEL} Reallocated: ${REALLOCATED} ]"
                        ;;
		*)
			echo "&red ${i} FAILED [ Serial:${SERIAL} Model:${MODEL} Reallocated: ${REALLOCATED} ]"
	esac
done)

STATUS="$(hostname) SMART health status"

if (echo ${MSG} | grep -q FAILED); then
	COLOR=red