From 122012ea31c818d58d7ce47d1201d2dacabd5c1c Mon Sep 17 00:00:00 2001 From: Andreas Hrubak Date: Wed, 2 Oct 2024 11:46:03 +0200 Subject: [PATCH] add S.M.A.R.T. data collector --- client/meter/smart | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 client/meter/smart diff --git a/client/meter/smart b/client/meter/smart new file mode 100755 index 0000000..e10c459 --- /dev/null +++ b/client/meter/smart @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +SMARTCTL() +{ + smartctl -i -H -A -f brief -n standby "$@" +} + +lsblk --list -o TYPE,RM,TRAN,PATH,MODEL,SERIAL | td-trans-fixcol -m 1 |\ +td-filter TYPE eq disk |\ +td-filter RM == 0 |\ +td-select -H PATH MODEL SERIAL |\ +while read -r devpath MODEL SERIAL +do + devbasename=${devpath##*/} + + IFS=$'\n' + for whole_line in `IFS=$'\n\t '; SMARTCTL "$devpath"` + do + IFS=$'\n\t ' + + read attrid attrname flags value worst threshold fail raw rest <<<"$whole_line" + + if [ "$attrid" -ge 0 -a "$value" -ge 0 -a "$worst" -ge 0 -a "$threshold" -ge 0 -a "$raw" -ge 0 ] 2>/dev/null + then + for leaf in value worst threshold raw + do + if [ $attrname = Unknown_Attribute ] + then + attrname=$attrid + else + attrname=${attrname,,} + attrname=${attrname//_/-} + fi + value=${!leaf} + echo "$MODEL.$SERIAL.$attrname.$leaf $value" + done + fi + done +done -- 2.11.4.GIT