Re: bdf one line output (1637 Views)
Reply
Trusted Contributor
Vishu
Posts: 407
Registered: ‎03-27-2007
Message 1 of 4 (1,637 Views)
Accepted Solution

bdf one line output

Hi Guys,

I have HP-UX 11.00 server. Below is the bdf output of it.

$ bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 1048576 41307 944370 4% /
/dev/vg00/lvol1 255253 74183 155544 32% /stand
/dev/vg00/lvol8 3145728 647245 2349665 22% /var
/dev/vg00/lvol7 1048576 561919 456264 55% /usr
/dev/vg00/lvpatrol 1024000 224406 749634 23% /usr/localcw/opt/patrol
/dev/vg00/lvol6 1572864 2057 1472672 0% /tmp
/dev/vg00/lvol5 1572864 898294 632427 59% /opt
/dev/vg00/lvol4 32768 3796 27186 12% /home
/dev/vg_glxy_02/obus_syb_fs
4104192 4750 3845593 0% /biller/obus_sybase
/dev/vg_glxy_02/obus_rep_fs
2052096 2281 1922348 0% /biller/obus_repserver

As you can see above, the last two FS of bdf comes in separate lines, but we run one script that need to have the one line output for every FS, and all fields of bdf are mandatory. That script is scheduled and run on many other servers also. I tried df -kp, but no use.

Is there anyway that we can get the one line output of every FS in bdf or any other command.

Thanks
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 4 (1,637 Views)

Re: bdf one line output

Hi:

This question arises frequently.

You could use:

# bdf | awk '{if (NF==1) {line=$0;getline;sub(" *"," ");print line$0} else {print}}'

OR:

You could avail yourself of a richly functional script by Bill Hassell which accomodates your requirement and much, much more. Bill's most recent version (5.2) is attached at the end of this thread:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1326767

Regards!

...JRF...


Honored Contributor
Suraj K Sankari
Posts: 1,659
Registered: ‎09-09-2008
Message 3 of 4 (1,637 Views)

Re: bdf one line output

Hi,
The best utility is bdfmesg created by Greate Bill H.
I am attaching the script download and enjoy..and thanks to Bill.

Suraj
Honored Contributor
Bill Hassell
Posts: 14,210
Registered: ‎05-29-2000
Message 4 of 4 (1,637 Views)

Re: bdf one line output

Split lines from bdf are always a problem, but there is an easy scripting method to handle it. Basically, you read the first line then check the 2nd variable (lvol size). If it doesn't have a value, read the rest of the values, like this:

bdf | while read FS TOT USED AVAIL PERCENT MNT
do
if [ $FS != "Filesystem" ] # skip the header
then
if [ "$TOT" = "" ] # must be a split line
then
read TOT USED AVAIL PERCENT MNT
fi
# here's the output
echo $FS $TOT $USED $AVAIL $PERCENT $MNT
fi
done

Attached is the latest version of bdfmegs. I made a change to the divisor from 1024 down to 1000. This makes the output match bdf. For your script to monitor space, you may find options -qP90 vey useful to provide a list of filesystems greater than 90% full and without any header:

bdfmegs -qP90

bdfmegs can also look at specific volume groups (-V option) or ignore specific volume groups (-N option).
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.