xymon-ext-scripts

Check-in [7b23404a7e]
Login

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

Overview
Comment: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)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: 7b23404a7e6231602646da5e91960284d723f7db0689ab8e545ca486ae35881d
User & Date: feld@FreeBSd.org 2017-05-25 22:10:55
Context
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
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
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

# 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}')
        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







>
>
>
>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

# 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