1

Would it be possible to add a "Mb" to the end of just MB_r/s and MB_wn/s. Awk is getting 3 fields and reporting them during the test line to line like below:

example: Format output below:

                            ^        ^              
90,    11 Kb,      12 Kb,    101253,    1.45,    1890.77,    427911.58
74,    11 Kb,      12 Kb,    101253,    1.45,    1890.77,    427911.58
89,    11 Kb,      12 Kb,    101253,    1.45,    1890.77,    427911.58

Command being used I need to have Mb on last 2 reported from awk.

iostat -m 3 2 |  grep dm-0 |awk '{a+=$2;b+=$3;c+=$4}END {print a"\n"b"\n"c"\n"}'

I want it to read like below example:

                                            ^          ^          
90,    11 Kb,      12 Kb,    101253,   1.45Mb,   1890.77Mb,    427911.58
74,    11 Kb,      12 Kb,    101253,   1.45Mb,   1890.77Mb,    427911.58
89,    11 Kb,      12 Kb,    101253,   1.45Mb,   1890.77Mb,    427911.58

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Queasy
  • 131
  • 11
  • not very sure how your format should look like. Use the `edit` button to prettify it. Also, indicate what is the normal output of `iostat`, we don't know what is the column with "MB_r/s", etc – fedorqui Mar 11 '15 at 16:15

1 Answers1

1

I actually found out how:

iostat -m 3 2 | grep dm-0 |awk '{a+=$2;b+=$3;c+=$4}END {print a"\n"b"Mb\n"c"Mb\n"}'

Worked perfectly :-).

Jotne
  • 40,548
  • 12
  • 51
  • 55
Queasy
  • 131
  • 11
  • you don't need grep and a pipe if you're using awk. Just use `iostat -m 3 2 |awk '/dm-0/{a+...`. Can't imagine how that command is producing the output you say you want but as long as you're happy... – Ed Morton Mar 11 '15 at 20:30