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 Side-by-Side Diffs Show Whitespace Changes Patch

Changes to smart.sh.

    44     44   
    45     45   # Xymon doesn't have /usr/local in PATH
    46     46   PATH=${PATH}:/usr/local/bin:/usr/local/sbin
    47     47   
    48     48   COLUMN=smart
    49     49   
    50     50   MSG=$(for i in $(sysctl -n kern.disks | tr ' ' '\n' | sort | egrep -v '^(cd|nvd)'); do
           51  +
           52  +	# Skip if listed in kern.disks but no device node exists
           53  +	if [ ! -e /dev/${i} ]; then
           54  +		continue;
           55  +	fi
           56  +
    51     57   	OUTPUT=$(sudo smartctl -a /dev/${i});
    52     58   	SERIAL=$(echo "${OUTPUT}" | awk '/Serial/ {print $3}')
    53     59           if [ "x${SERIAL}" == "x" ]; then SERIAL="null"; fi
    54     60   	MODEL=$(echo "${OUTPUT}" | awk '/Device Model/ {print $3,$4}')
    55     61           if [ "x${MODEL}" == "x" ]; then MODEL="null"; fi
    56     62   	REALLOCATED=$(echo "${OUTPUT}" | awk '/Reallocated_Sector/ {print $10}')
    57     63           if [ "x${REALLOCATED}" == "x" ]; then REALLOCATED=0; fi