Commit 9dbf3ad1 authored by Dan Reading's avatar Dan Reading

Strengthen logic/better code in write-cache reporting. Look for new formatting...

Strengthen logic/better code in write-cache reporting. Look for new formatting given by newer smartctl
parent 84a86a8d
......@@ -574,22 +574,14 @@ findSmartctl() {
return 0
}
findSmartctl_getopt() {
local findit=$(which smartctl)
if [ -z "${findit}" ] ; then
# didn't findit try other location
if [ -x "/usr/sbin/smartctl" ]; then
findit="/usr/sbin/smartctl"
else
findit=$NOSM
fi
fi
# if found check functionally
if [ "${findit}" != "$NOSM" ] ; then
x=$(${findit} --get | grep REQUIRED)
[[ -z "$x" ]] && findit=$NOSM
local smrtctl=$(findSmartctl)
if [ "${smrtctl/smartctl}" != "$smrtctl" ] ; then
# check functionally
x=$($smrtctl --get | grep REQUIRED)
[[ -z "$x" ]] && smrtctl=$NOSM
fi
echo $findit
echo $smrtctl
return 0
}
......
......@@ -119,8 +119,6 @@ main_diskcheck() {
$wspeed_val ) d[$wspeed_val]="\"UNKNOWN\"" ;;
$rspeed ) d[$rspeed]="RSPEED=" ;;
$rspeed_val ) d[$rspeed_val]="\"UNKNOWN\"" ;;
$rspeed ) d[$rspeed]="RSPEED=" ;;
$rspeed_val ) d[$rspeed_val]="\"UNKNOWN\"" ;;
esac
done
......@@ -523,18 +521,18 @@ getwcache() {
hdp=$(which hdparm)
if [ "${hdp/hdparm}" != "${hdp}" ] ; then
x=$(hdparm -W $1 2>/dev/null | grep -i 'write-caching')
if [ "${x/on}" == "$x" ] ; then
res="disabled"
else
if [ "${x/on}" != "$x" ] ; then
res="enabled"
elif [ "${x/off}" != "$x" ] ; then
res="disabled"
fi
fi
else
x=$($smtcl --get=wcache $1 | grep -i 'Write cache')
if [ "${x/Enabled}" == "$x" ] ; then
res="disabled"
else
x=$($smtcl --get=wcache $1 | grep -i Write | grep -i cache)
if [ "${x/Enabled}" != "$x" ] ; then
res="enabled"
elif [ "${x/Disabled}" != "$x" ] ; then
res="disabled"
fi
fi
fi
......@@ -544,20 +542,20 @@ getwcache() {
#don't have smartctl, maybe we can use camcontrol
cmc=$(which camcontrol)
if [ "${cmc/camcontrol}" != "${cmc}" ] ; then
sd=${1#/dev/}
sd=${1#/dev/}
x=$(camcontrol modepage $sd -m8 | grep WCE 2>/dev/null)
if [ "${x/1}" == "$x" ] ; then
res="disabled"
else
if [ "${x/1}" != "$x" ] ; then
res="enabled"
elif [ "${x/0}" != "$x" ] ; then
res="disabled"
fi
fi
else
x=$($smtcl --get=wcache $1 | grep -i 'Write cache')
if [ "${x/Enabled}" == "$x" ] ; then
res="disabled"
else
x=$($smtcl --get=wcache $1 | grep -i Write | grep -i cache)
if [ "${x/Enabled}" != "$x" ] ; then
res="enabled"
elif [ "${x/Disabled}" != "$x" ] ; then
res="disabled"
fi
fi
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment