Sponsored Content
Top Forums Shell Programming and Scripting summing up iostat values in AIX Post 302366812 by mkastin on Friday 30th of October 2009 11:20:03 AM
Old 10-30-2009
Not the best way to do it, but it'll work....

Code:
$ iostat -d 2 2 | awk '{if(NR > 3 && NR < 6) SUM1 += $2; if(NR > 7 && NR < 10) SUM2 += $2 } END { print "iteration 1:" SUM1 "  iteration 2:" SUM2 }'

iteration 1:7.43  iteration 2:4.96

or

Code:
iostat -d 2 2 | awk '{if(NR > 3 && NR < 6) SUM1 += $2; if(NR > 7 && NR < 10) SUM2 += $2 } END { print SUM1 "\n" SUM2 }'

7.43
4.96

This is simple and won't loop for more iterations.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help wantyed to understand iostat -D in AIX 5.3

Hi, I am new to AIX and I am trying to look into a performance issue with an C-Isam based application that uses Asynchronous IO. I ran iostat -D to have a look at the disks and saw what seemed to be some big figures ocurring in the queues section such as waits in the service queue of 3.1... (2 Replies)
Discussion started by: Harpo_HK
2 Replies

2. UNIX for Advanced & Expert Users

Equivalent for iostat -e in AIX HP-UX Linux

iostat -e gives the soft, hard and transport error information in Solaris. What is the equivalent command in the other flavors of Unix AIX HP Linux. Thanks Prasi (1 Reply)
Discussion started by: prasi_in
1 Replies

3. UNIX for Dummies Questions & Answers

sar and iostat recommended interval/count values.

Hi, I got a request from a client to check on their server's cpu, memory and disk utilization. Am planning to use the sar and iostat commands to achieve this. The server is used for sending and receiving messages between the stockbrokers, so I was thinking to run the commands during the market... (9 Replies)
Discussion started by: 60doses
9 Replies

4. Shell Programming and Scripting

summing values of a column

I have a file which contains data as below: ----------------------------------------------------------------------------------------------- GSPWeb Statistics for the period of last 20 days... (3 Replies)
Discussion started by: mohsin.quazi
3 Replies

5. Shell Programming and Scripting

Awk: Summing values with group criteria

Hi Guys, I have a text file with ";" like separator F1;F2;F3;F4;F5 444;100041;IT;GLOB;1800000000 444;100041;TM;GLOB;1000000000 444;10300264;IT;GLOB;2000000000 444;10300264;IT;GLOB;2500000000 I have to sum the cullums F5 for same F2 and F3 collums The result must be: ... (7 Replies)
Discussion started by: gianluca2
7 Replies

6. Shell Programming and Scripting

Summing values in columns

Basically I have to process a text file which has been sorted this way: John 12 John 13 John 10 John 900 Peter 20 Peter 30 Peter 32 The first column is a name, and the second an arbitrary value, both delimited by a space. How can I sum them up such that it would become: John 935... (2 Replies)
Discussion started by: Dwee
2 Replies

7. Shell Programming and Scripting

reading a script and summing some values

I need help reading and summing some values in a file that looks like the following. This is an Oracle trace file. Oracle has as utility to do this,but it doesn't work properly unless my sql statement is done. I want to read the file and sum up some values to let me know how the query/job is... (0 Replies)
Discussion started by: guessingo
0 Replies

8. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

9. Shell Programming and Scripting

Summing up values of rows of numbers

data file contains failed=24 error=23 error=163 failed=36 error=903 i need to get a total count of each value above. i'm looking for the most efficient method to do this as the datafile i provided is just a sample. the actual data can be several hundred thousands of lines. so from... (3 Replies)
Discussion started by: SkySmart
3 Replies

10. Solaris

Asvc_t values in iostat output

Noticed that asvc_t values in iostat command outputs are mostly more than 100 in our previous iostat analysis. Also found the following detail from an alternate site IO Bottleneck - Disk performance issue - UnixArena ---- 1. asvc_t average service time of active transactions, in... (2 Replies)
Discussion started by: saraperu
2 Replies
foreach(n)						       Tcl Built-In Commands							foreach(n)

__________________________________________________________________________________________________________________________________________________

NAME
foreach - Iterate over all elements in one or more lists SYNOPSIS
foreach varname list body foreach varlist1 list1 ?varlist2 list2 ...? body _________________________________________________________________ DESCRIPTION
The foreach command implements a loop where the loop variable(s) take on values from one or more lists. In the simplest case there is one loop variable, varname, and one list, list, that is a list of values to assign to varname. The body argument is a Tcl script. For each element of list (in order from first to last), foreach assigns the contents of the element to varname as if the lindex command had been used to extract the element, then calls the Tcl interpreter to execute body. In the general case there can be more than one value list (e.g., list1 and list2), and each value list can be associated with a list of loop variables (e.g., varlist1 and varlist2). During each iteration of the loop the variables of each varlist are assigned consecutive values from the corresponding list. Values in each list are used in order from first to last, and each value is used exactly once. The total number of loop iterations is large enough to use up all the values from all the value lists. If a value list does not contain enough elements for each of its loop variables in each iteration, empty values are used for the missing elements. The break and continue statements may be invoked inside body, with the same effect as in the for command. Foreach returns an empty string. EXAMPLES
This loop prints every value in a list together with the square and cube of the value: set values {1 3 5 7 2 4 6 8} ;# Odd numbers first, for fun! puts "Value Square Cube" ;# Neat-looking header foreach x $values { ;# Now loop and print... puts " $x [expr {$x**2}] [expr {$x**3}]" } The following loop uses i and j as loop variables to iterate over pairs of elements of a single list. set x {} foreach {i j} {a b c d e f} { lappend x $j $i } # The value of x is "b a d c f e" # There are 3 iterations of the loop. The next loop uses i and j to iterate over two lists in parallel. set x {} foreach i {a b c} j {d e f g} { lappend x $i $j } # The value of x is "a d b e c f {} g" # There are 4 iterations of the loop. The two forms are combined in the following example. set x {} foreach i {a b c} {j k} {d e f g} { lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" # There are 3 iterations of the loop. SEE ALSO
for(n), while(n), break(n), continue(n) KEYWORDS
foreach, iteration, list, looping Tcl foreach(n)
All times are GMT -4. The time now is 08:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy