xymon-ext-scripts

Check-in [e11222ca76]
Login

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

Overview
Comment:Handle situations where disk does not expose SMART data such as USB drives Also support NVMe disks properly by converting nvd -> nvme
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: e11222ca76012800741e114e957d7a513dfa9c3d58e108b43cfb285a14b2356e
User & Date: feld 2018-10-30 16:45:41
Context
2018-10-31
14:30
Handle disk overheat situation separately from a FAILURE Leaf check-in: 34345518e8 user: feld tags: master, trunk
2018-10-30
16:45
Handle situations where disk does not expose SMART data such as USB drives Also support NVMe disks properly by converting nvd -> nvme check-in: e11222ca76 user: feld tags: master, trunk
2017-05-25
22:10
Add logic to skip if a disk in kern.disks but missing a device node This happens if you have a powered off USB drive (usbconfig -d ugenX.Y power_off) check-in: 7b23404a7e user: feld@FreeBSd.org 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
# 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

	# Skip if listed in kern.disks but no device node exists
	if [ ! -e /dev/${i} ]; then
		continue;
	fi

	OUTPUT=$(sudo smartctl -a /dev/${i});




	SERIAL=$(echo "${OUTPUT}" | awk '/Serial/ {print $3}')
        if [ "x${SERIAL}" == "x" ]; then SERIAL="null"; fi
	MODEL=$(echo "${OUTPUT}" | awk '/Device Model/ {print $3,$4}')
        if [ "x${MODEL}" == "x" ]; then MODEL="null"; fi
	REALLOCATED=$(echo "${OUTPUT}" | awk '/Reallocated_Sector/ {print $10}')
        if [ "x${REALLOCATED}" == "x" ]; then REALLOCATED=0; fi
	TEMP=$(echo "${OUTPUT}" | awk '/Temperature_Celsius/ {print $10}')







|







>
>
>
>







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
# 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 | sed 's,nvd,nvme,g' | tr ' ' '\n' | sort | egrep -v '^(cd|nvd)'); do

	# Skip if listed in kern.disks but no device node exists
	if [ ! -e /dev/${i} ]; then
		continue;
	fi

	OUTPUT=$(sudo smartctl -a /dev/${i});
        if [ $? -eq 1 ]; then
          # SMART status not available for this disk
          continue
        fi
	SERIAL=$(echo "${OUTPUT}" | awk '/Serial/ {print $3}')
        if [ "x${SERIAL}" == "x" ]; then SERIAL="null"; fi
	MODEL=$(echo "${OUTPUT}" | awk '/Device Model/ {print $3,$4}')
        if [ "x${MODEL}" == "x" ]; then MODEL="null"; fi
	REALLOCATED=$(echo "${OUTPUT}" | awk '/Reallocated_Sector/ {print $10}')
        if [ "x${REALLOCATED}" == "x" ]; then REALLOCATED=0; fi
	TEMP=$(echo "${OUTPUT}" | awk '/Temperature_Celsius/ {print $10}')