[checkmk-commits] Check_MK Git: check_mk: * use persistent device names from /dev/disk/by-id/ ... instead of /dev/sd[a-z] * support for SMART temperature on SCSI/ SAS Disks

git version control git at mathias-kettner.de
Fri Oct 5 12:07:46 CEST 2012


Module: check_mk
Branch: master
Commit: 5916c61feeeff95f7c84809b0bbc15a8ba5e7f7a
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5916c61feeeff95f7c84809b0bbc15a8ba5e7f7a

Author: Raoul Gunnar Borenius <borenius at dfn.de>
Date:   Fri Oct  5 11:11:46 2012 +0200

* use persistent device names from /dev/disk/by-id/... instead of /dev/sd[a-z] * support for SMART temperature on SCSI/SAS Disks

Signed-off-by: Raoul Gunnar Borenius <borenius at dfn.de>

---

 agents/plugins/smart |   58 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/agents/plugins/smart b/agents/plugins/smart
index 0890c85..c9e6682 100755
--- a/agents/plugins/smart
+++ b/agents/plugins/smart
@@ -2,20 +2,35 @@
 
 # Only handle always updated values, add device path and vendor/model
 if which smartctl > /dev/null 2>&1 ; then
+    #
+    # if the 3ware-utility is found
+    # get the serials for all disks on the controller
+    #
+    if which tw_cli > /dev/null 2>&1 ; then
+	# support for only one controller at the moment
+	TWAC=$(tw_cli show | awk 'NR < 4 { next } { print $1 }' | head -n 1)
+	
+	# add a trailing zero to handle case of unused slot
+	# trailing zeros are part of the device links in /dev/disk/by-id/... anyway
+	# hopefully this doesn't change with new kernels
+	eval `tw_cli /$TWAC show drivestatus | grep -E '^p[0-9]' | awk '{print $1 " " $7 "0"}' | while read twaminor serial ; do
+	    twaminor=${twaminor#p}
+	    serial=AMCC_${serial}00000000000
+	    echo "$serial=$twaminor"
+        done`
+    fi
+
     echo '<<<smart>>>'
-    for D in /dev/[sh]d[a-z] /dev/[sh]d[a-z][a-z]; do
-        N=${D##*/}
+    for D in /dev/disk/by-id/scsi-*; do
+        [ "$D" != "${D%-part*}" ] && continue
+        N=$(readlink $D)
+        N=${N##*/}
         if [ -r /sys/block/$N/device/vendor ]; then
             VEND=$(tr -d ' ' < /sys/block/$N/device/vendor)
         else
             # 2012-01-25 Stefan Kaerst CDJ - in case $N does not exist
             VEND=ATA
         fi
-        # 2012-01-25 Stefan Kaerst CDJ - special option in case vendor is AMCC
-        if [ "$VEND" == "AMCC" ]; then
-            D='/dev/twa0'
-            SPECOPS='-d 3ware,0'
-        fi
         if [ -r /sys/block/$N/device/model ]; then
             MODEL=$(sed -e 's/ /_/g' -e 's/_*$//g' < /sys/block/$N/device/model)
         else
@@ -24,6 +39,33 @@ if which smartctl > /dev/null 2>&1 ; then
         if [ "$MODEL" = "iSCSI_Disk" ]; then
             continue
         fi
-        smartctl $SPECOPS -v 9,raw48 -A $D | grep Always  | egrep -v '^190(.*)Temperature(.*)' | sed "s|^|$D $VEND $MODEL |"
+
+	# strip device name for final output
+	DNAME=${D#/dev/disk/by-id/scsi-}
+        # 2012-01-25 Stefan Kaerst CDJ - special option in case vendor is AMCC
+	CMD=
+        if [ "$VEND" == "AMCC" -a -n "$TWAC" ]; then
+	    DNAME=${DNAME#1}
+	    [ -z "${!DNAME}" ] && continue
+	    CMD="smartctl -d 3ware,${!DNAME} -v 9,raw48 -A /dev/twa0"
+	    # create nice device name including model
+	    MODEL=$(tw_cli /$TWAC/p${!DNAME} show model | head -n 1 | awk '{ print $4 }')
+	    DNAME=${DNAME#AMCC_}
+	    DNAME="AMCC_${MODEL}_${DNAME%000000000000}"
+        elif [ "$VEND" != "ATA" ] ; then
+	    TEMP=
+	    # create temperature output as expected by checks/smart
+	    # this is a hack, TODO: change checks/smart to support SCSI-disks
+	    eval `smartctl -d scsi -i -A $D | while read a b c d e ; do
+		[ "$a" == Serial ] && echo SN=$c
+		[ "$a" == Current -a "$b" == Drive  -a "$c" == Temperature: ] && echo TEMP=$d
+	    done`
+	    [ -n "$TEMP" ] && CMD="echo 194 Temperature_Celsius 0x0000 000 000 000 Old_age Always - $TEMP (0 0 0 0)"
+	    DNAME="SCSI_${VEND}_${MODEL}_${SN}"
+	else
+	    CMD="smartctl -d ata -v 9,raw48 -A $D"
+	fi
+	
+        [ -n "$CMD" ] && $CMD | grep Always | egrep -v '^190(.*)Temperature(.*)' | sed "s|^|$DNAME $VEND $MODEL |"
     done 2>/dev/null
 fi



More information about the checkmk-commits mailing list