New version, bug fix for mdraid, and cleaned up some errors and weak spots in component

output for mdraid. Certain conditions would trigger a false return for raid components, now
it shows more explicitly the online/spare/failed data so it's clear. Also shows 'none' for 
online if none are detected.
This commit is contained in:
inxi-svn 2013-02-27 22:02:44 +00:00
parent c4be977f5c
commit 2a93e5e522
2 changed files with 29 additions and 9 deletions

23
inxi
View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
#### Version: 1.8.39
#### Version: 1.8.40
#### Date: February 27 2013
#### Patch Number: 00
########################################################################
@ -6643,7 +6643,7 @@ get_raid_data()
# also correct possible weird formats for the output from older kernels etc.
mdstat="$( sed -e 's/^md/\nmd/' -e 's/^unused[[:space:]]/\nunused /' \
-e 's/read_ahead/\nread_ahead/' -e 's/^resync=/\nresync=/' -e 's/^Event/\nEvent/' \
-e 's/^[[:space:]]*$//' -e 's/[[:space:]]read_ahead/\nread_ahead/' <<< "$mdstat" )"
-e 's/^[[:space:]]*$//' -e 's/[[:space:]]read_ahead/\nread_ahead/' <<< "$mdstat" )"
# some fringe cases do not end as expected, so need to add newlines plus EOF to make sure while loop doesn't spin
mdstat=$( echo -e "$mdstat\n\nEOF" )
@ -6699,7 +6699,7 @@ get_raid_data()
if ( $0 ~ /^md/ ) {
device = gensub(/(md.*)[[:space:]]?:/, "\\1", "1", $1 )
}
if ( $0 ~ /raid[0-9]+/ ) {
if ( $0 ~ /mirror|raid[0-9]+/ ) {
raidLevel = gensub(/(.*)raid([0-9]+)(.*)/, "\\2", "g", $0 )
}
if ( $0 ~ /(active \(auto-read-only\)|active|inactive)/ ) {
@ -6772,7 +6772,7 @@ get_raid_data()
temp_array=${A_RAID_DATA[@]}
log_function_data "A_RAID_DATA: $temp_array"
# echo -e "A_RAID_DATA:\n${A_RAID_DATA[@]}"
# echo -e "A_RAID_DATA:\n${temp_array}"
eval $LOGFE
}
@ -9486,16 +9486,16 @@ print_raid_data()
component=$( sed 's/\[[0-9]\+\]//' <<< $component )
fi
# NOTE: for bsd zfs, states are: ONLINE,DEGRADED,OFFLINE (at least)
if [[ -n $( grep -Ei '(F|DEGRADED)' <<< $component ) ]];then
if [[ -n $( grep -E '(F|DEGRADED)' <<< $component ) ]];then
component=$( sed -e 's/(F)//' -e 's/F//' -e 's/DEGRADED//' <<< $component )
failed="$failed $component"
component=''
elif [[ -n $( grep -Ei '(S|OFFLINE)' <<< $component ) ]];then
elif [[ -n $( grep -E '(S|OFFLINE)' <<< $component ) ]];then
component=$( sed -e 's/(S)//' -e 's/S//' -e 's/OFFLINE//' <<< $component )
spare="$spare $component"
component=''
else
device_components=$device_components$component_separator$component
device_components="$device_components$component_separator$component"
component_separator=' '
fi
done
@ -9506,12 +9506,17 @@ print_raid_data()
if [[ $spare != '' ]];then
spare=" ${C1}spare${SEP3}${C2}$spare${C2}"
fi
if [[ $device_components != '' ]];then
if [[ -n $device_components || -n $spare || -n $failed ]];then
if [[ $B_EXTRA_DATA != 'true' && -z $BSD_TYPE ]];then
if [[ $device_report != 'N/A' ]];then
if [[ $device_report != 'N/A' && -n $device_components ]];then
device_components="$device_report - $device_components"
fi
fi
if [[ $device_components == '' ]];then
device_components='none'
fi
device_components="${C1}online${SEP3}${C2} $device_components"
device_components=" ${C1}components${SEP3}${C2} $device_components$failed$spare"
fi
fi

View file

@ -1,3 +1,18 @@
=====================================================================================
Version: 1.8.40
Patch Version: 00
Script Date: February 27 2013
-----------------------------------
Changes:
-----------------------------------
New version, bug fix for mdraid, and cleaned up some errors and weak spots in component
output for mdraid. Certain conditions would trigger a false return for raid components, now
it shows more explicitly the online/spare/failed data so it's clear. Also shows 'none' for
online if none are detected.
-----------------------------------
-- Harald Hope - Wed, 27 Feb 2013 14:00:46 -0800
=====================================================================================
Version: 1.8.39
Patch Version: 00