- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: count number of objects and total
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
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
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
08-27-2012 02:50 AM
08-27-2012 02:50 AM
Hi
Please can someone help with a script
I have a file with the following
disk1:appvg:36864
disk21:appvg:76800
disk2:datavg:102400
disk3:datavg:102400
disk4:datavg:204800
disk6:datavg:204800
disk16:datavg01:102400
disk17:datavg01:512000
disk18:datavg01:512000
disk19:datavg01:512000
disk22:datavg:122880
disk23:datavg:51200
disk5:dumpvg:307200
disk16:datavg01:102400
disk17:datavg01:512000
1st field is the LUN 2nd field is the VG and the 3rd field is the LUN size
I want to output this information as so
VG:LUNSIZE:NUMBER OF LUNS AT THE LUNSIZE:LUN SIZE TOTAL
any help is greatly appreciated
Thanks
Chris.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2012 03:04 AM
08-27-2012 03:04 AM
Re: count number of objects and total
You probably want to use awk's arrays. Perhaps like:
awk -F: '
{
vg[$2] += $3 # add up size per VG
vg_size[$2,$3] += 1
}
END {
# output array values
}' input-file
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2012 03:39 AM
08-27-2012 03:39 AM
Re: count number of objects and total
ok so thats a start but what i am finding is that each LUN per VG is being totalled but I cannot see the total number of luns at that size
ie
datavg has 4 LUNS, 2 at 2048MB, 1 at 5120MB and 1 and 10240MB totalling 1024TB
disk6:datavg:204800
disk7:datavg:204800
disk8:datavg:512000
disk9:datavg:102400
so the output I want to see is
datavg:204800:2:409600
datavg:512000:1:512000
etc ....
the total per VG isnt that important.
I can have a play around with your example and see what I come up with
thanks Dennis
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2012 08:59 PM
08-27-2012 08:59 PM
Solution>but I cannot see the total number of luns at that size
Right, I didn't get that far. Try this:
awk -F: '
BEGIN {
OFMT = "%.0f"
OFS = ":"
}
{
vg[$2] += $3 # add up size per VG, not used
vg_size[$2 ":" $3] += 1 # count number of VG:LUN sizes
}
END {
# output array values
# for (key in vg) print key, vg[key]
for (key in vg_size) {
split(key, array_index) # break apart array key
size = vg_size[key] * array_index[2]
print key, vg_size[key], size
}
}' input-file | sort