1834007 Members
1566 Online
110063 Solutions
New Discussion

bdf in one line

 
SOLVED
Go to solution
Printaporn_1
Esteemed Contributor

bdf in one line

Hi All,

I have bdf display like this :
/dev/vgx1dsbu01/lvol1
104837120 5162184 93445258 5% /u01
/dev/vgx1dsbu02/lvol1
104837120 28898601 71192430 29% /u02
/dev/vgx1dsbu03/lvol1
104837120 31605129 68654996 32% /u03
/dev/vgx1dsbu04/lvol1
104837120 55150449 46581321 54% /u04
/dev/vgx1dsbu05/lvol1
-----------

because I have long vgname then bdf did not display in one line.
How can I make bdf display each file system in one line cause my script to check file system will fail.

thanks in advance,
enjoy any little thing in my life
10 REPLIES 10
KapilRaj
Honored Contributor

Re: bdf in one line

1. You may try df instead of bdf
Or
you may store everyline in a var and then print the odd \n even

you want me to work out one for you ?

Regds,

Kaps
Nothing is impossible
Mark Grant
Honored Contributor

Re: bdf in one line

You need to change your script to cope with this I'm afraid. It's irritating but everyone ends up having to do this. I have attached a perl script that does a lot more than you want but inside it is some code you can cut out.

It's not just long volume group names that can cause you a problem. NFS mounts do to. Also, on solaris you have the additional problem of swap and /proc.

Never preceed any demonstration with anything more predictive than "watch this"
Printaporn_1
Esteemed Contributor

Re: bdf in one line

Hi Kapil,

Please help me.

Hi Mark,

Your script is excellent but it is too complicate for me.

Thanks,
enjoy any little thing in my life
Chris Wilshaw
Honored Contributor
Solution

Re: bdf in one line

I use

df -lk | awk '{if(match($1,"\/") == 1)
FSN = $1
LVOL = (substr($2,2,30))
KT = $(NF - 3)
getline;KA = $1
getline;KU = $1
getline;PU = $1
{printf "%-30s%10s%10s%10s%5s%% %-10s\n",LVOL,KT,KU,KA,PU,FSN}}' | sort -rnk 5

This reformats the df output into a bdf-like view, but with each filesystem only using a single line, sorted so that the filesystem with the highest % used is at the top of the list


eg:

/dev/vg00/lvol3 199242 115245 83997 57% /
/dev/vg00/lvol5 1994023 1136417 857606 56% /opt
/dev/vg00/lvol4 974962 239147 735815 24% /home
/dev/vg00/lvol7 3888053 767928 3120125 19% /usr
/dev/vg00/lvol1 272812 46358 226454 16% /stand
/dev/vg00/lvol8 3875707 564364 3311343 14% /var
/dev/vg00/lvol6 963360 44364 918996 4% /tmp
Printaporn_1
Esteemed Contributor

Re: bdf in one line

Hi Chris,

thanks for your script but a little more help.
I am dump with scriping.
How can I have the heading like bdf

Filesystem kbytes used avail %used Mounted on
enjoy any little thing in my life
KapilRaj
Honored Contributor

Re: bdf in one line

Pipe the bdf out put to the following command

grep -v Filesystem |awk '{if (NF == "1") printf $0 ;else printf $0 "\n"}'


i.e.

bdf |grep -v Used |awk '{if (NF == "1") printf $0 ;else printf $0 "\n"}'

I tried this on linux now let me know if it doesn't work there

Regds,

Kaps
Nothing is impossible
Chris Wilshaw
Honored Contributor

Re: bdf in one line

You can just add the line

printf "%-30s%10s%10s%10s%5s %-10s\n" Filesystem kbytes used avail %used Mounted_on

to the start of the script
Bill Hassell
Honored Contributor

Re: bdf in one line

This is the simplest method using shell scripting:

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

Of course, if your terminal width is not wide enough, long lines may get truncated or wrap at the right edge.

You might want to use bdfmegs (attached) which makes the fields smaller (Mbytes, not Kbytes) but still keeps each mountpoint on one line.


Bill Hassell, sysadmin
Geoff Wild
Honored Contributor

Re: bdf in one line

Here's one I use called bdfmegs - output like:

File System Mbytes Used Avail %Used Mounted on
/dev/vg00/lvol3 200 166 34 83% /
/dev/vg00/lvol1 292 53 209 20% /stand
/dev/vg00/lvol8 4600 1662 2917 36% /var
/dev/vg00/lvol13 2048 1005 978 51% /var/opt/perf/datafiles
/dev/vg01/lvol2 12288 4 11901 0% /var/adm/crash
/dev/vg00/lvol7 2048 1395 649 68% /usr
/dev/vg00/lvol14 512 167 324 34% /usr/openv
/dev/vg00/lvol4 512 54 455 11% /tmp
/dev/vg00/lvol6 2048 1462 582 72% /opt
/dev/vg00/lvol12 256 6 234 3% /opt/cctool
/dev/vg00/lvol10 24 2 21 8% /ops
/dev/vg00/lvol5 512 194 315 38% /home
/dev/vg00/lvol11 1024 167 803 17% /data
/dev/vg00/lvol9 1536 363 1100 25% /app
pctransf:/export/usr/sap/trans 6144 2006 3886 34% /usr/sap/trans
iprdbf:/export/sapmnt/IPR 10240 2853 7182 28% /sapmnt/IPR
iprdbf:/export/data/sap/IPR/ARCHIVE 129424 123001 6373 95% /data/sap/IPR/ARCHIVE
iprdbf:/export/sapmnt/IPR 10240 2853 7182 28% /sapmnt/IPR
/dev/vg57/lvol3 8192 69 7869 1% /var/adm/lp
/dev/vg57/lvol4 17176 2005 14939 12% /var/spool/lp
/dev/vg57/lvol1 256 126 122 51% /etc/lp
/dev/vg57/lvol2 256 188 64 75% /var/sam/lp
pctransf:/export/usr/sap/trans 6144 2006 3886 34% /usr/sap/trans
iprdbf:/export/data/sap/IPR/ARCHIVE 129424 123001 6373 95% /data/sap/IPR/ARCHIVE


Don't know if that will cut'n'paste nicely....

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Jdamian
Respected Contributor

Re: bdf in one line

I make this script some time ago...