xymon-ext-scripts

Check-in [b701d7442e]
Login

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

Overview
Comment:Remove some needless greps in favor of awk Add checking and reporting of disk temperature Filter out nvd devices which aren't actually disks, but I may want to add logic to convert these to nvme equivalents...
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:b701d7442e5002882c17920c430908b9497e7a12c54f1a1d3c0581e257ae16d6
User & Date: feld@feld.me 2017-03-14 15:15:13
Context
2017-05-25
21:58
Fix monitoring logic for smart.sh Introduce yellow for when we cannot get valid data from SMART for some reason check-in: 59939734bb user: feld@FreeBSd.org tags: master, trunk
2017-03-14
15:15
Remove some needless greps in favor of awk Add checking and reporting of disk temperature Filter out nvd devices which aren't actually disks, but I may want to add logic to convert these to nvme equivalents... check-in: b701d7442e user: feld@feld.me tags: master, trunk
2016-08-16
00:05
Always check kernel version from uname, otherwise you can be fooled into believing you've booted into the updated kernel check-in: bbfdb16dd8 user: feld@feld.me tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to smart.sh.

43
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
# Now restart the xymon client to start using it.

# 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







|

|
|
|
>


>
>






|


|







43
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
74
75
76
# Now restart the xymon client to start using it.

# 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|nvd)'); do
	OUTPUT=$(sudo smartctl -a /dev/${i});
	SERIAL=$(echo "${OUTPUT}" | awk '/Serial/ {print $3}')
	MODEL=$(echo "${OUTPUT}" | awk '/Device Model/ {print $3,$4}')
	REALLOCATED=$(echo "${OUTPUT}" | awk '/Reallocated_Sector/ {print $10}')
	TEMP=$(echo "${OUTPUT}" | awk '/Temperature_Celsius/ {print $10}')
	if [ ${REALLOCATED} -gt 0 ] ; then
		HEALTH="FAILED"
	elif [ ${TEMP} -gt 45 ] ; 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} Temp: ${TEMP} ]"
                        ;;
		*)
			echo "&red ${i} FAILED [ Serial: ${SERIAL} Model: ${MODEL} Reallocated: ${REALLOCATED} Temp: ${TEMP} ]"
	esac
done)

STATUS="$(hostname) SMART health status"

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