- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Calculating Disk usage
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 06:53 PM
06-24-2003 06:53 PM
Given a PV I have to calculate the sum of free space on all file systems on that PV. I need to do this programatically, so API(s) would be really helpful.
Thanks and regards
Sonison James
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:26 PM
06-24-2003 07:26 PM
SolutionSee if this small script helps you.
#!/usr/bin/ksh
if [ $# -ne 1 ]
then
echo "Usage: $0 PV"
exit
fi
/usr/sbin/pvdisplay -v $1 > /tmp/pv$$ 2>&1
if [ $? != 0 ]
then
echo "$1 is not a PV"
exit
fi
for LV in $(awk '/current/ {print $3}' /tmp/pv$$|sort|uniq)
do
bdf $LV > /tmp/pv$$ 2>&1
if [ $? = 0 ]
then
FREE=$(df -k $LV|awk '/free/ {print $1}')
echo $LV ${FREE} KB
else
echo "$LV failed"
fi
done
rm /tmp/pv$$
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 07:27 PM
06-24-2003 07:27 PM
Re: Calculating Disk usage
Not entirely sure what you are trying to achieve but the following may help.
First you need to determine which filesystems are on that PV.
Issue the following command:
# pvdisplay -v
This will show you which LV's are using space on that PV. You can then do a bdf and look at the free space for that LV (filesystem). Remember that LV's (filesystems) can span multiple disks. You can check which PV's an LV is using by:
# lvdisplay -v
eg lvdisplay -v /dev/vg01/lvol3
To calculate how much free space is on the PV look for "Free PE" value in the pvdisplay output.
You need to multiply the Free PE value by the PE size (this can seen in the vgdisplay output) to get free space on the PV in Mbytes.
I have attached a script which may help you in analysing your disk usage.
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:23 PM
06-24-2003 08:23 PM
Re: Calculating Disk usage
Sri your script seems to solved my problem except for some 'failed' messages that I get for some LVs. Please see the output that I got for one PV:
[james@c test]$ ./diskinfo /dev/dsk/c1t15d0
/dev/vg00/lv_cpifs 926844 KB
/dev/vg00/lv_i2nj 4462177 KB
/dev/vg00/lvol1 211224 KB
/dev/vg00/lvol2 failed
/dev/vg00/lvol3 123224 KB
/dev/vg00/lvol4 176480 KB
/dev/vg00/lvol5 278864 KB
/dev/vg00/lvol6 147752 KB
/dev/vg00/lvol7 303280 KB
/dev/vg00/lvol8 1197752 KB
Am I doing something wrong or is there an error?
Thanks and regards
Sonison James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:25 PM
06-24-2003 08:25 PM
Re: Calculating Disk usage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:27 PM
06-24-2003 08:27 PM
Re: Calculating Disk usage
Since /dev/vg00/lvol2 is the primary swap to most HP-UX machines, therefore it is not a filesystem and hence it fails during bdf.
So in other words, those "failed" LVs are not filesystems but raw devices.
Hope this can help.
Kenneth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:28 PM
06-24-2003 08:28 PM
Re: Calculating Disk usage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:29 PM
06-24-2003 08:29 PM
Re: Calculating Disk usage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:31 PM
06-24-2003 08:31 PM
Re: Calculating Disk usage
lvol2 will fail in vg00 as it is primary swap, nothing to worry about.
Sri - thats a nice script.
Should have mentioned my script is only designed if bdf output is on one line.
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:39 PM
06-24-2003 08:39 PM
Re: Calculating Disk usage
If any of the logical volumes is not a filesystem, then it cannot calculate the free space and will display the message "failed". If you don't like the word "failed", replace it with "undetermined" in the script. I wrote it on the fly to give you an idea so I didn't pay much attention to the messages.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 08:55 PM
06-24-2003 08:55 PM
Re: Calculating Disk usage
Kenneth, Sri and Con thanks for the information, this has solved my problem. Twang thanks for the script.
Regards
Sonison James