Commit cb1ec7d3 authored by Vinicius Ruoso's avatar Vinicius Ruoso

Fixed language problems on raid related scripts

When detecting if a disk is with I/O error a different message was beeing
returned depending on the system language. Exporting the LC_ALL variable
will force the message to be in english.
Signed-off-by: default avatarVinicius Ruoso <vkr07@c3sl.ufpr.br>
parent dbde2dce
#!/bin/bash
# export to correctly get english language
export LC_ALL=C
# function to print stuff
function print(){
printf "PRD_FIXRAID+$*\n"
......
#!/bin/bash
# export to correctly get english language
export LC_ALL=C
# raid must be enabled
if ! test -e /proc/mdstat; then
MSG="PRD_RAID+STATUS+NOTEXIST"
# raid5 are ignored
elif grep -q "md.*raid5" /proc/mdstat; then
MSG="PRD_RAID+STATUS+RAID 5"
# check if raid have some problem
elif grep -q "_" /proc/mdstat; then
MSG="PRD_RAID+STATUS+DEGRADED+"
# some disk are not there
if ! test -e /dev/sda; then
MSG="$MSG sda_MISSING"
elif ! test -e /dev/sdb; then
MSG="$MSG sdb_MISSING"
# some disk with IO error
elif grep -q "read error" <<< $(sfdisk -d /dev/sda 2>&1); then
MSG="$MSG sda_IOERROR"
elif grep -q "read error" <<< $(sfdisk -d /dev/sdb 2>&1); then
MSG="$MSG sdb_IOERROR"
# check for faulty partitions
elif grep -q "\(F\)" /proc/mdstat; then
FAULTY=$(grep "\(F\)" /proc/mdstat |awk -F"\(F" '{print $1}'|
awk '{print $NF}' |sed -e "s/\[.*\]//")
for FAULT in $FAULTY; do
MSG="$MSG ${FAULT}_FAULTY"
done
# other issues: disk sync, out of array or partitions missing
else
for MDSTAT in $(grep '_' /proc/mdstat|cut -db -f1);do
if grep -B1 $MDSTAT /proc/mdstat|head -1|grep -q sda; then
......@@ -45,10 +63,10 @@ else
MSG="PRD_RAID+STATUS+OK"
fi
# just print the diagnose message
if test "$MSG" = "RAID+STATUS+DEGRADED+"; then
printf "PRD_RAID+STATUS+DEGRADED+NOINFO"
else
MSG=$(sed "s/DEGRADED+ /DEGRADED+/g" <<< "$MSG")
printf "$MSG\n"
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