Re: need in 'bdf' script (130 Views)
Reply
Advisor
Onur Karakan
Posts: 21
Registered: ‎12-15-2005
Message 1 of 4 (130 Views)
Accepted Solution

need in 'bdf' script

Hi everybody
i wrote a script that informs you about the lv usage, if the usage is more than a value.(if lv name is long 'bdf' writes some values to the next line.) my problem is, this script never gives the last value of bdf. please try it in your system. and please help. :) i think there is a small trick, but i could not find.
arper=gives %usage
arpernxt=gives %usage (if lv name is long and %usage at the next line)

export date=`date +%d_%m_%y`
set -A arper $(bdf|awk '{print $5}'|cut -f1 -d "%")
set -A arpernxt $(bdf|awk '{print $4}'|cut -f1 -d "%")

set -A armnt $(bdf|awk '{print $6}'|cut -f1 -d "%")
set -A armntnxt $(bdf|awk '{print $5}'|cut -f1 -d "%")

i=0
echo "Total number of lv:"${#arper[@]}
while (( $i < ${#arper[@]} ))
do
if [[ ${arper[$i]} > 64 || ${arpernxt[$i+1]} > 64 ]]
then
if [ ${arper[$i]} ]
then

case "${arper[$i]}" in
[0-9]*)
echo ${arper[$i]} ${armnt[$i+1]}
;;
*)
echo ${arpernxt[$i+1]} ${armntnxt[$i]}
;;
esac
fi
fi
i=$(($i+1))
done
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 4 (130 Views)

Re: need in 'bdf' script

Hi:

Bill Hassell has addressed this before. See here, for instance:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=214093&admit=-682735245+1134656...

Regards!

...JRF...
Honored Contributor
Bill Hassell
Posts: 14,226
Registered: ‎05-29-2000
Message 3 of 4 (130 Views)

Re: need in 'bdf' script

As mentioned in the reply from James, bdf does indeed break up the line into two parts. The simplest solution is to read all the values for each line and if the trailing values are empty, read again. The breakpoint for bdf is always the same. Here is a snippet of code:

bdf -l |
while read FS TOT USED AVAIL PERCENT MNT
do
if [ "$TOT" = "" ]
then
read TOT USED AVAIL PERCENT MNT
fi
print $FS $TOT $USED $AVAIL $PERCENT $MNT
done

This will normalize bdf into all 1-line strings for each mountpoint.
Advisor
Onur Karakan
Posts: 21
Registered: ‎12-15-2005
Message 4 of 4 (130 Views)

Re: need in 'bdf' script

Thank you so much.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.