fix some parsing of smart-intercept-spindown broken by new version

New smart-intercept-spindown didn't accept all formats of input coming
to it - the status line we were trying to detect broken status of
doesn't appear on most devices
This commit is contained in:
Tim Connors 2025-09-20 06:23:00 +10:00
parent f8e4bf0dc8
commit 8ea6df0eb3
2 changed files with 83 additions and 73 deletions

View file

@ -404,8 +404,8 @@ sub set_fans_servo {
# to tiny spikes of 1 fan unit. FIXME: But should implement long # to tiny spikes of 1 fan unit. FIXME: But should implement long
# term smoothing of +/- 1 fan unit # term smoothing of +/- 1 fan unit
my $demand_has_changed = !defined $lastfan or my $demand_has_changed = !defined $lastfan or
$demand < $lastfan or ($demand < $lastfan) or
$demand > $lastfan + $hysteresis; ($demand > $lastfan + $hysteresis);
if ($print_stats or if ($print_stats or
$demand_has_changed) { $demand_has_changed) {
if ($demand_has_changed) { if ($demand_has_changed) {

View file

@ -24,80 +24,90 @@ convert_sas() {
device_product= device_product=
data= data=
local exit_code=0 local exit_code=0
while read line ; do exit_condition=false
case "$read_initial,$read_data,$line" in {
true,false,*DATA\ SECTION*) read line || exit_condition=true
read_initial=false while ! $exit_condition ; do
read_data=true case "$read_initial,$read_data,$line" in
echo "Device Model: $device_vendor $device_product" true,false,*DATA\ SECTION*)
echo read_initial=false
echo "$line" read_data=true
echo "Device Model: $device_vendor $device_product"
echo
echo "$line"
read line read line
if [[ "$line" == SMART\ Health\ Status:*OK ]] ; then if [[ "$line" == SMART\ Health\ Status: ]] ; then
exit_code=0 if [[ "$line" == *OK ]] ; then
else exit_code=0
exit_code=8 else
fi exit_code=8
echo "$line" fi
echo "$line"
echo
read line
fi
echo "ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE" echo "ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE"
;; continue # reparse the new line
true,false,Vendor:*) ;;
device_vendor="$( echo "$line" | sed 's/Vendor: *//' )" true,false,Vendor:*)
echo "$line" device_vendor="$( echo "$line" | sed 's/Vendor: *//' )"
;; echo "$line"
true,false,Product:*) ;;
device_product="$( echo "$line" | sed 's/Product: *//' )" true,false,Product:*)
echo "$line" device_product="$( echo "$line" | sed 's/Product: *//' )"
;; echo "$line"
true*) ;;
echo "$line" true*)
;; echo "$line"
false,true,Current\ Drive\ Temperature:*) ;;
temp="$( echo "$line" | sed 's/.*Temperature: *// ; s/ C$//' )" false,true,Current\ Drive\ Temperature:*)
;; temp="$( echo "$line" | sed 's/.*Temperature: *// ; s/ C$//' )"
false,true,Drive\ Trip\ Temperature:*) ;;
temp_threshold="$( echo "$line" | sed 's/.*Drive Trip Temperature: *// ; s/ C$//' )" false,true,Drive\ Trip\ Temperature:*)
hundred_minus_temp="$( printf "%03.f" "$( echo "100 - $temp" | bc -l )" )" temp_threshold="$( echo "$line" | sed 's/.*Drive Trip Temperature: *// ; s/ C$//' )"
echo "194 Temperature_Celsius null $hundred_minus_temp $hundred_minus_temp 000 Old_age Always - $temp (Min/Max 0/$temp_threshold)" hundred_minus_temp="$( printf "%03.f" "$( echo "100 - $temp" | bc -l )" )"
;; echo "194 Temperature_Celsius null $hundred_minus_temp $hundred_minus_temp 000 Old_age Always - $temp (Min/Max 0/$temp_threshold)"
false,true,Accumulated\ power\ on\ time,\ hours:minutes:*) ;;
hours="$( echo "$line" | sed 's/.*hours:minutes // ; s/:.*//' )" false,true,Accumulated\ power\ on\ time,\ hours:minutes:*)
# minutes="$( echo "$line" | sed 's/.*hours:minutes // ; s/.*://' )" hours="$( echo "$line" | sed 's/.*hours:minutes // ; s/:.*//' )"
# hours="$( echo "scale=2 ; $hours + $minutes/60" | bc -l )" # minutes="$( echo "$line" | sed 's/.*hours:minutes // ; s/.*://' )"
echo "9 Power_On_Hours null 100 100 000 Old_age Always - $hours" # hours="$( echo "scale=2 ; $hours + $minutes/60" | bc -l )"
;; echo "9 Power_On_Hours null 100 100 000 Old_age Always - $hours"
false,true,Specified\ cycle\ count\ over\ device\ lifetime:*) ;;
start_stop_cycles_threshold="$( echo "$line" | sed 's/.*Specified cycle count over device lifetime: *//' )" false,true,Specified\ cycle\ count\ over\ device\ lifetime:*)
;; start_stop_cycles_threshold="$( echo "$line" | sed 's/.*Specified cycle count over device lifetime: *//' )"
false,true,Accumulated\ start-stop\ cycles:*) ;;
start_stop_cycles="$( echo "$line" | sed 's/.*Accumulated start-stop cycles: *//' )" false,true,Accumulated\ start-stop\ cycles:*)
hundred_minus_cycles="$( printf "%03.f" "$( echo "100 - 100*$start_stop_cycles/$start_stop_cycles_threshold" | bc -l )" )" start_stop_cycles="$( echo "$line" | sed 's/.*Accumulated start-stop cycles: *//' )"
echo "12 Power_Cycle_Count null $hundred_minus_cycles $hundred_minus_cycles 000 Pre-fail Always - $start_stop_cycles" hundred_minus_cycles="$( printf "%03.f" "$( echo "100 - 100*$start_stop_cycles/$start_stop_cycles_threshold" | bc -l )" )"
;; echo "12 Power_Cycle_Count null $hundred_minus_cycles $hundred_minus_cycles 000 Pre-fail Always - $start_stop_cycles"
false,true,Specified\ load-unload\ count\ over\ device\ lifetime:*) ;;
load_unload_cycles_threshold="$( echo "$line" | sed 's/.*Specified load-unload count over device lifetime: *//' )" false,true,Specified\ load-unload\ count\ over\ device\ lifetime:*)
;; load_unload_cycles_threshold="$( echo "$line" | sed 's/.*Specified load-unload count over device lifetime: *//' )"
false,true,Accumulated\ load-unload\ cycles:*) ;;
load_unload_cycles="$( echo "$line" | sed 's/.*Accumulated load-unload cycles: *//' )" false,true,Accumulated\ load-unload\ cycles:*)
hundred_minus_cycles="$( printf "%03.f" "$( echo "100 - 100*$load_unload_cycles/$load_unload_cycles_threshold" | bc -l )" )" load_unload_cycles="$( echo "$line" | sed 's/.*Accumulated load-unload cycles: *//' )"
echo "193 Load_Cycle_Count null $hundred_minus_cycles $hundred_minus_cycles 000 Pre-fail Always - $load_unload_cycles" hundred_minus_cycles="$( printf "%03.f" "$( echo "100 - 100*$load_unload_cycles/$load_unload_cycles_threshold" | bc -l )" )"
;; echo "193 Load_Cycle_Count null $hundred_minus_cycles $hundred_minus_cycles 000 Pre-fail Always - $load_unload_cycles"
false,true,Elements\ in\ grown\ defect\ list:*) ;;
defects="$( echo "$line" | sed 's/.*Elements in grown defect list: //' )" false,true,Elements\ in\ grown\ defect\ list:*)
echo "5 Reallocated_Sector_Ct null 100 100 001 Pre-fail Always - $defects" defects="$( echo "$line" | sed 's/.*Elements in grown defect list: //' )"
;; echo "5 Reallocated_Sector_Ct null 100 100 001 Pre-fail Always - $defects"
false,true,Non-medium\ error\ count:*) ;;
errors="$( echo "$line" | sed 's/.*Non-medium error count: //' )" false,true,Non-medium\ error\ count:*)
echo "1 Raw_Read_Error_Rate null 100 100 001 Pre-fail Always - $errors" errors="$( echo "$line" | sed 's/.*Non-medium error count: //' )"
;; echo "1 Raw_Read_Error_Rate null 100 100 001 Pre-fail Always - $errors"
*) ;;
data="$data *)
data="$data
$line" $line"
;; ;;
esac esac
done <<< "$1" read line || exit_condition=true
done
} <<< "$1"
if [ -n "$data" ] ; then if [ -n "$data" ] ; then
echo echo
echo "=== SAS DATA ===" echo "=== SAS DATA ==="