Operating System - HP-UX
1847230 Members
2504 Online
110263 Solutions
New Discussion

total disk space used /free .. gigs..

 
someone_4
Honored Contributor

total disk space used /free .. gigs..

Hey everyone
Is there a command that will give me the total disk space used and free in gigs?

Thanks,
Richard
17 REPLIES 17
Patrick Wallek
Honored Contributor

Re: total disk space used /free .. gigs..

There's nothing native to HP-UX.

Here's a little awk script that will total up the columns of bdf output for you:


bdf -l | awk '{ if ( $1 > 0 )
{ total+=$1;totused+=$2;totfree+=$3 }
else
{ total+=$2;totused+=$3;totfree+=$4 }
}
END {OFMT="%.2f";print "Total Space Used =",totused/1048576,"GB. Total Space Allocated =",total/1048576,"GB. Total Space Free=",totfree/1048576,"GB."}'
James George_1
Trusted Contributor

Re: total disk space used /free .. gigs..

not heard of anyhting for that so far...anxious to know from others..
I will do bdf and do the calculations to get the Gigs

James
forum is for techies .....heaven is for those who are born again !!
Helen French
Honored Contributor

Re: total disk space used /free .. gigs..

Hi Richard,

Not sure about a HP-UX command which directly reports disk space in Gbytes (most of the time listing in Kbytes or Mbytes). However, you can do simple calculations on the outputs of following commands:

1) bdf ( lists file system usage in Kbytes )
2) du -k ( directory usage in Kbytes )
3) pvdisplay ( PV usage; multiply PE size with total PE ; in Mbytes)
4) vgdisplay ( VG usage; multiply PE size with total PE; in Mbytes)
5) lvdisplay ( lv size in Mbytes)
6) SAM ( displays all disk information)
7) STM ( online diag )

HTH,
Shiju
Life is a promise, fulfill it!
Sanjay_6
Honored Contributor

Re: total disk space used /free .. gigs..

Hi Richard,

you can look at the script posted by Andreas Voss in the link below,

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xfb046d96588ad4118fef0090279cd0f9,00.html

Hope this helps.

Regds
harry d brown jr
Honored Contributor

Re: total disk space used /free .. gigs..

Richard,

bdf|grep -v Filesystem|tr -s " " " "|cut -d" " -f 1-4|sort|
awk 'BEGIN {
prev="";
totals[0]=0;
totals[1]=0;
totals[2]=0;
gtotals[0]=0;
gtotals[1]=0;
gtotals[2]=0;
printf("%4s %14s %14s %14s\n","VG","Size","In use","Available");
}
{split($1,curr,"/");
if (prev!="" && prev!=curr[3])
{printf("%4s %14d %14d %14d\n",prev,totals[0],totals[1],totals[2]
);
gtotals[0]+=totals[0];
gtotals[1]+=totals[1];
gtotals[2]+=totals[2];
totals[0]=0;
totals[1]=0;
totals[2]=0;
}
prev=curr[3];
totals[0]+=$2;
totals[1]+=$3;
totals[2]+=$4;
}
END {
gtotals[0]+=totals[0];
gtotals[1]+=totals[1];
gtotals[2]+=totals[2];
printf("%4s %14d %14d %14d\n",prev,totals[0],totals[1],totals[2]);
printf("%4s %14s %14s %14s\n","----","--------------","-------------
-","--------------");
printf("%4s %14d %14d %14d\n","Totl",gtotals[0],gtotals[1],gtotals[2
]);
}'

to modify for gb's just add the division of 1gb to the output.

live free or die
harry
Live Free or Die
Michael Tully
Honored Contributor

Re: total disk space used /free .. gigs..

Hi Richard,

I sort of got lost trying to read Harry's script, so I now feel like a little bit of comedy.... get a calculator!

Cheers!
Michael
Anyone for a Mutiny ?
harry d brown jr
Honored Contributor

Re: total disk space used /free .. gigs..

Michael,

You haven't had enough to drink yet :-)) I'll help you out, but I usually don't drink beer, so I'll bring some Wild Turkey : - )


live free or die
harry
Live Free or Die
Michael Tully
Honored Contributor

Re: total disk space used /free .. gigs..

Bit early for me Harry.... It's only 9AM... I at least wait until the sun is around the yard arm! (Midday)

Cheers
hiccup
-Michael
Anyone for a Mutiny ?
Alan Riggs
Honored Contributor

Re: total disk space used /free .. gigs..

I would like to give proper gredit, but I have forgotten where I stole this script from. It is called bdfmegs and outputs (obviously) in megabytes. To generate output in GB simply change '1024" to '1048576'.
Volker Borowski
Honored Contributor

Re: total disk space used /free .. gigs..

Hi,

Linux knows "df -h" -h for HUMAN.

Calculates to K, M, G according to size of filesystem.

May be you can get the source compiled to HPUX
Volker
someone_4
Honored Contributor

Re: total disk space used /free .. gigs..

Hey Harry .. lets see if you are still reading this post .. but I get an error when I try to run your script.

syntax error The source line is 14.
The error context is
{printf("%4s %14d %14d %14d\n",prev,totals[0],totals[1],totals[2
] >>>
<<<
awk: The statement cannot be correctly parsed.
The source line is 14.
awk: The string ---------- cannot contain a newline character.
The source line is 32.
awk: There is a missing ) character.


Richard
Patrick Wallek
Honored Contributor

Re: total disk space used /free .. gigs..

Richard,

attached is the corrected script that harry gave. The problem(s) is when you just cut and paste from the window, there are some lines that wrapped to a new line that shouldn't have. I have fixed it on my machine for you.

Patrick Wallek
Honored Contributor

Re: total disk space used /free .. gigs..

Crazy thing didn't attach. Let's try this again.
Patrick Wallek
Honored Contributor

Re: total disk space used /free .. gigs..

Here is harry's script modified so that it gives you the output in GB to 2 decimal precision.
Patrick Wallek
Honored Contributor

Re: total disk space used /free .. gigs..

OK. Sorry for all these attachments. Ignore the last one. It wasn't completely set up to convert to GB.

This one should be.
someone_4
Honored Contributor

Re: total disk space used /free .. gigs..

Hey Patrick you think too much coffe this morning?

Richard
harry d brown jr
Honored Contributor

Re: total disk space used /free .. gigs..

Thanks Patrick! Should we also add in VG info, as in free extents, used, and allocated?

live free or die
harry
Live Free or Die