Operating System - HP-UX
1820475 Members
3005 Online
109624 Solutions
New Discussion юеВ

calculating total and free disk space on a system

 
SOLVED
Go to solution
Amit Manna_4
Occasional Advisor

calculating total and free disk space on a system

hi
Is there any script for calculating the total and free disk space left on a HP Unix system

Regards
14 REPLIES 14
James R. Ferguson
Acclaimed Contributor

Re: calculating total and free disk space on a system

Hi Amit:

Define "free".

If you mean "free" spaces within mounted filesystems, use 'bdf'. If you mean free physical disk extents within LVM volume groups, start with 'vgdisplay'. If you mean "unused" physical disks, tell us how you know they are truly unused if they could be raw volumes.

Regards!

...JRF...
Amit Manna_4
Occasional Advisor

Re: calculating total and free disk space on a system

HI James
I want to calculate the free space in the VGs.

When we give vgdisplay command we get alloc Pe and Free PE.

I want to calculate the sum of all free space left and total allocated space left in VG.
I am looking for a script to do so

Regards
Amit Manna


Vishu
Trusted Contributor

Re: calculating total and free disk space on a system

Hi Amit,

What output you want exactly. Free disk space in a VG, you can find with vgdisplay command. In a disk, you can find with pvdisplay command. bdf tells you the free space in the FS.

Or, please elaborate your question on what else you need.

Vishu
Trusted Contributor

Re: calculating total and free disk space on a system

**When we give vgdisplay command we get alloc Pe and Free PE.**

vgdisplay will tell this information only i.e.

Total PE - Total disk space alloted to that VG.

Alloc PE - Disk space allocated to LVs in that VG.

Free PE - Unused Disk space in that VG.

But you need to see the PE size of that VG, which helps you calculate the space in MB. To calculate the space, use the formula:-

Space(MB) = PE Size * No. of PEs
Roopesh Francis_1
Trusted Contributor

Re: calculating total and free disk space on a system

vgdisplay|grep "VG Name"|awk '{print $3}|'|while read a
do
vgdisplay $a|grep "PE Size"|awk '{print $4}'|read b
vgdisplay $a|grep "Total PE"|awk '{print $3}'|read c
vgdisplay $a|grep "Free PE"|awk '{print $3}'|read d
echo "$a $(b*c) $(b*d)"
done

first column will be vg name second column will be total size of vg and third column will be free space in VG
Vinod Kumar Yadav
Trusted Contributor

Re: calculating total and free disk space on a system

Hi,

For Calculating Total Disk with & Free Disk Space with the VG.


Please follow the below step.
Run the command vgdiaply

#root # vgdisplay
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 17
Open LV 17
Max PV 16
Cur PV 4
Act PV 4
Max PE per PV 4384
VGDA 8
PE Size (Mbytes) 4
Total PE 17394
Alloc PE 6019
Free PE 11375
Total PVG 2
Total Spare PVs 0
Total Spare PVs in use 0

Cur PV - 4 - Means 4 Disk are using with the VG00

Free PE - 11375 - Means Free space Avilable on the VG.

For Calcuting the Total Free Space in the VG
is.

PE Size * Free PE = Total Free Space

Example - 4*11375 = 45500 is the Free Space in the VG


Thanks
Vinod Kumar Yadav



Jai Shiv Shankar
Roopesh Francis_1
Trusted Contributor

Re: calculating total and free disk space on a system

small correction in the previous post
vgdisplay|grep "VG Name"|awk '{print $3}|'|while read a
do
vgdisplay $a|grep "PE Size"|awk '{print $4}'|read b
vgdisplay $a|grep "Total PE"|awk '{print $3}'|read c
vgdisplay $a|grep "Free PE"|awk '{print $3}'|read d
echo "$a $((b*c)) $((b*d))"
done

first column will be vg name second column will be total size of vg and third column will be free space in VG









Amit Manna_4
Occasional Advisor

Re: calculating total and free disk space on a system

The above is not working


Regards
Amit Manna
Roopesh Francis_1
Trusted Contributor

Re: calculating total and free disk space on a system

paste the output
Viktor Balogh
Honored Contributor
Solution

Re: calculating total and free disk space on a system

here it is corrected:

vgdisplay 2>/dev/null |grep "VG Name"|awk '{print $3}'|while read a
do
vgdisplay $a|grep "PE Size"|awk '{print $4}'|read b
vgdisplay $a|grep "Total PE"|awk '{print $3}'|read c
vgdisplay $a|grep "Free PE"|awk '{print $3}'|read d
echo "$a $((b*c)) $((b*d))"
done



it should work like a charm:

# vgdisplay 2>/dev/null |grep "VG Name"|awk '{print $3}'|while read a
> do
> vgdisplay $a|grep "PE Size"|awk '{print $4}'|read b
> vgdisplay $a|grep "Total PE"|awk '{print $3}'|read c
> vgdisplay $a|grep "Free PE"|awk '{print $3}'|read d
> echo "$a $((b*c)) $((b*d))"
> done
/dev/vg00 139968 63712
/dev/vghomeora 139968 103968
/dev/vgquorum1 14368 13856
/dev/vgignite 115072 30336
#
****
Unix operates with beer.
Viktor Balogh
Honored Contributor

Re: calculating total and free disk space on a system

there was a pipe in the first line at the end of the awk statement ;)
(and i added the error redirection just to don't get confused because of disabled VGs)
****
Unix operates with beer.
Sharma Sanjeev
Respected Contributor

Re: calculating total and free disk space on a system

@Ranju Did you read the question, Amit is asking how to see total & free space available in VG's & need script, if you have so many VG's in system OMG

@Amit, Please find attached script, which will give total size of vg, Free size in VG

Regards
Sanjeev
Everything is Possible as " IMPOSSIBLE" word itself says I M POSSIBLE
Amit Manna_4
Occasional Advisor

Re: calculating total and free disk space on a system

hi Sanjeev
Can we get the sum of total space and free space in all VGs?


Regards
Sharma Sanjeev
Respected Contributor

Re: calculating total and free disk space on a system

Amit

Yes, With this Script you can have both

Regards
Sanjeev
Everything is Possible as " IMPOSSIBLE" word itself says I M POSSIBLE