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
# term smoothing of +/- 1 fan unit
my $demand_has_changed = !defined $lastfan or
$demand < $lastfan or
$demand > $lastfan + $hysteresis;
($demand < $lastfan) or
($demand > $lastfan + $hysteresis);
if ($print_stats or
$demand_has_changed) {
if ($demand_has_changed) {

View file

@ -24,7 +24,10 @@ convert_sas() {
device_product=
data=
local exit_code=0
while read line ; do
exit_condition=false
{
read line || exit_condition=true
while ! $exit_condition ; do
case "$read_initial,$read_data,$line" in
true,false,*DATA\ SECTION*)
read_initial=false
@ -34,14 +37,19 @@ convert_sas() {
echo "$line"
read line
if [[ "$line" == SMART\ Health\ Status:*OK ]] ; then
if [[ "$line" == SMART\ Health\ Status: ]] ; then
if [[ "$line" == *OK ]] ; then
exit_code=0
else
exit_code=8
fi
echo "$line"
echo
read line
fi
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: *//' )"
@ -64,8 +72,8 @@ convert_sas() {
;;
false,true,Accumulated\ power\ on\ time,\ hours:minutes:*)
hours="$( echo "$line" | sed 's/.*hours:minutes // ; s/:.*//' )"
# minutes="$( echo "$line" | sed 's/.*hours:minutes // ; s/.*://' )"
# hours="$( echo "scale=2 ; $hours + $minutes/60" | bc -l )"
# minutes="$( echo "$line" | sed 's/.*hours:minutes // ; s/.*://' )"
# 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:*)
@ -97,7 +105,9 @@ convert_sas() {
$line"
;;
esac
done <<< "$1"
read line || exit_condition=true
done
} <<< "$1"
if [ -n "$data" ] ; then
echo
echo "=== SAS DATA ==="