- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sums averages in using expr, awk
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
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
тАО11-10-2004 08:05 AM
тАО11-10-2004 08:05 AM
I am using vmstat and sar, piping output to flat files for some long term performance monitoring.
I want want to create a script that builds a running average of CPU idle, and memory use.
I will have columnar data, I want to summarize daily data files, with sums and averages using "expr", and "awk".
Basically from vmstat out put I will keep a timestamp, avg, free.
I will do something similar with "sar", capturing CPU1 idle, CPU2 idle, and timestamp.
Basically,
I want to create a running average, and a daily average
if Free is Column 2 I want to sum the column and divide by "wc -l"
If someone can show me a quicky on how to use an expr to sum my columns I can probably figure the rest out.
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2004 08:10 AM
тАО11-10-2004 08:10 AM
Re: sums averages in using expr, awk
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2004 08:11 AM
тАО11-10-2004 08:11 AM
Re: sums averages in using expr, awk
awk 'BEGIN{s=0;n=0};{n++;s=s+$2};END{print $s/$n}' myinputfile
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2004 08:13 AM
тАО11-10-2004 08:13 AM
Re: sums averages in using expr, awk
(( TOTAL_CPU1 = $TOTAL_CPU1 + SAR_CPU1 ))
where you can use some looping mechanism of your choice (for, while, etc) to loop through the file or variable where you've captured the sar data to be totaled.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2004 08:16 AM
тАО11-10-2004 08:16 AM
Re: sums averages in using expr, awk
in the awk
'BEGIN{s=0;n=0};{n++;s=s+$2};END{print $s/$n}'
is the $2 the column of which I want to sum?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2004 08:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-10-2004 08:44 AM
тАО11-10-2004 08:44 AM
Re: sums averages in using expr, awk
Did it!!