- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell , awk or perl script
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
Discussions
Discussions
Discussions
Forums
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
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
тАО04-26-2007 04:54 AM
тАО04-26-2007 04:54 AM
I am looking for a script which will print vg name associated with each physical volume on an hpux system.
It should scan all the volume groups & disks on the system (vgdisplay -v & ioscan -fnkC disk) and then format the output in the following format.
/dev/dsk/c0t6d0 vg00
/dev/dsk/c0t5d0 vg00
/dev/dsk/c0t1d0 none
/dev/dsk/c0t2d01 vg01
I tried writing a shell script but it is too long .. I am sure there could be a perl or awk solution to this. I would appreciate any help on this...
Regards,
Kaps
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2007 05:24 AM
тАО04-26-2007 05:24 AM
Re: Shell , awk or perl script
vgdisplay 2>/dev/null | grep "VG Name" | awk '{print $NF}' | xargs -n1 | while read VGNAME
do
vgdisplay -v ${VGNAME} | grep dsk | awk -v VG=${VGNAME} '{print $3,VG}'
done
If the disk is not displayed in the vgdisplayed, then either the disk is not currently part of any volume group, an alternate link that is not added to the VG or it is part of the volume group that is not active.
So, I dont know how useful traversing through the output of ioscan will be.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2007 05:25 AM
тАО04-26-2007 05:25 AM
Re: Shell , awk or perl script
Such a script is fraught with danger. How do you propose to determine that a disk is unused? Just because it isn't currently a part of LVM or VxVM doesn't mean that it is unused. You could be using raw devices -- a very common practice with databases and a less common practice with other applications. Moreover, even if the disk is unused on this system does not mean that it is not in use on another system. The only way that I ever do this is document, document, document so that I never have to ask "Now what does this disk or LUN do?".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2007 06:12 AM
тАО04-26-2007 06:12 AM
SolutionGive this semi-tested shell script a try:
#!/usr/bin/sh
for HWP in $(ioscan -FkC disk | cut -d: -f11)
do
set -A HWOUT $(ioscan -fnH ${HWP})
CAND=${HWOUT[((${#HWOUT[*]}-2))]}
RC=$(echo ${CAND} | grep -qE '^/dev/dsk/')
if [ "${RC}" -eq "0" ]
then
VG=$(pvdisplay ${CAND} 2>/dev/null |\
awk '{if($1=="VG"&&$2=="Name"){sub(/\/dev\//,""); print $3}}')
echo ${CAND} ${VG:-none}
fi
done
exit 0
I try to account for the case where ioscan detects a disk device that doesn't have a corresponding device file with the first usage of ioscan. Since none of my systems meets this criterion (and I don't feel like removing device files), some guesswork is involved here.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2007 06:30 AM
тАО04-26-2007 06:30 AM
Re: Shell , awk or perl script
Thanks for your time and I will get back asap.
Regards,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2007 06:39 AM
тАО04-26-2007 06:39 AM
Re: Shell , awk or perl script
Regards, Kaps