Operating System - HP-UX
1824169 Members
2958 Online
109669 Solutions
New Discussion юеВ

script to find the space of all VG

 
SOLVED
Go to solution
Karuppiah_1
Occasional Contributor

script to find the space of all VG

Hi All,

Do anybody having script...
1.to extract and display the physical free disk connected to system but unallocated to any VG.
2.to calculate and display the disk space available/allocated/free in Gb for all the VGs in the system.

Thanks in advance.

GK


6 REPLIES 6
Rodney Hills
Honored Contributor

Re: script to find the space of all VG

Here is a small perl script that I use.

HTH

-- Rod Hills
There be dragons...
James R. Ferguson
Acclaimed Contributor

Re: script to find the space of all VG

Hi:

Insofar as calculating the free disk connected to a system, this is potentially misleading. If a disk isn't recorded in '/etc/lvmtab' it may merely mean that is has not been 'vgimported' but otherwise has valid data that should not be destroyed.

As for calculating the available, allocated and free counts in all volume groups, you can use parse the output of:

# vgdisplay -v

For each 'VG Name' you will have a 'PE Size' whose value (in MBytes) can be multiplied by the VG's "Alloc PE" and "Free PE' to obtain the per-VG space. Repeat for all volume groups and sum to yield an overall summary of disk space.

Regards!

...JRF...

Prashant Zanwar_4
Respected Contributor

Re: script to find the space of all VG

for vg in /dev/vg*
do
vgdisplay $vg | awk '/VG Name/{VG=$3}/Free PE/{FREE=$3}END{print VG, FREE}'
done

this shall work to know HOW much free space you have..

You can modify this to get space in MB or likewise..

Thanks
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: script to find the space of all VG

Danger Will Robinson!!! It is very difficult to determine if a disk is not being used. Disks under control of LVM and/or VxVM are easy to find. Disks that are used as whole disks either for filesystems or as swapspace are also easy to find (swapinfo, /etc/fstab) BUT disks which are used as raw disks by applications such as databases are very, very easy to mistake as "unused" -- but at least with databases you know to look for them. Other applications might also use raw disks and these are very easy to miss --- until you use them as part of LVM and the the application explodes.

The only way to know this is a very disciplined documentation process as new disks and LUN's are added or removed.
If it ain't broke, I can fix that.
Prashant Zanwar_4
Respected Contributor

Re: script to find the space of all VG

You might have multiple path's connected to your sysem, so same disk having different address is possible, and if it is cluster it would be more difficult, as chances are what is not used but visible on one host, is used on other host..

scripting surely can acheive this..

Every environment is different, so you need to let people details know like what enviornment you have..

One good approach - which is semi manual, here I am assuming you have alternate paths allocated to your VG's

vgdisplay -v | grep -i dsk 2> /dev/null 1> /tmp/disks_in_use

symcfg list - shall tell what EMC frames are local to host ..

sympd -sid list -- list of all disk from a specific frame of EMC.

sympd -sid list --- here you have to grep for devices which you use, one which you dont use can be left like BCV, R2 etc.

Once you have All R1/RAID 5 etc meta list, you compare with one used in VG..

grep has great functionality which can help in it..


Good luck
Prashant









"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Tom Smith_9
Frequent Advisor

Re: script to find the space of all VG

Here is a perl I use to report on VG usage.

Hope it helps.