Monitor the iowait in a server

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Krietjur
Posts: 14
Joined: Thu Dec 01, 2005 8:15 am
Location: Holten, the Netherlands
Contact:

Post by Krietjur »

I have the same problem here. What is your output from the iostat command?

When I do iostat, I get a result like this:

avg-cpu: %user %nice %sys %idle
0.65 0.00 0.48 98.87


When I looked on the internet for iostat and iowait, I found out that the output should look like this:
avg-cpu: %user %nice %sys %iowait %idle
4.92 0.00 0.78 0.77 93.53

So, there's no iowait field in my iostat command :( And that's just the thing I want to monitor.. any suggestions on this issue?

I've installed iostat from sysstat-4.0.7-4.i386.rpm, server is running Red Hat Enterprise.
Krietjur
Posts: 14
Joined: Thu Dec 01, 2005 8:15 am
Location: Holten, the Netherlands
Contact:

Post by Krietjur »

I don't get it :roll: I installed the sysstat package on a debian testmachine. There the command shows iowait info. But when I run the top command on that server, it doesn't show iowait. On my redhat server, it shows iowait for each cpu (it has 8 cpu's) when I use the top command, but not with the iostat command.. :cry:
Krietjur
Posts: 14
Joined: Thu Dec 01, 2005 8:15 am
Location: Holten, the Netherlands
Contact:

Post by Krietjur »

I upgraded to newer version of sysstat on my Redhat server, and now it also shows iowait in the iostat command. But the command to create the html page from a previous post, still gives the same error. But I can live with that, I'll just write my own script ;)
mp72@excite.com
Posts: 3
Joined: Wed May 16, 2007 11:26 am

Re: Error

Post by mp72@excite.com »

dinfiesta wrote:Runing this on my redhat (I do have iostat installed)

iostat -t 1 16|tail -n 15| awk '{n++;user+=$(NF-3);sys+=$(NF-2);idle+=$(NF-1);iowait+=$(NF)} END{print "user:"user/n " sys:"sys/n " idle:"idle/n " iowait:"iowait/n}' > /tmp/iostat.html

I get this error:

awk: cmd. line:1: (FILENAME=- FNR=3) fatal: attempt to access field -3

Any ideas?
This seems to work on RHEL4 for me:
iostat -t 1 16|tail -n 13 | head -n 1 | awk '{n++;user+=$(NF-3);sys+=$(NF-2);idle+=$(NF-1);iowait+=$(NF)} END{print "user:"user/n " sys:"sys/n " idle:"idle/n " iowait:"iowait/n}'
user:0 sys:10.72 idle:0 iowait:0
themattreid
Posts: 2
Joined: Tue Sep 01, 2009 12:00 pm

Post by themattreid »

RHEL5 / CentOS 5.3 command that works:

Code: Select all

ROOT-(2)>iostat -t 1 2 | head -n 5 | tail -n 1 | awk {'print "iowait="$4'}

iowait=0.04

ROOT-(0)> cat /etc/redhat-release
CentOS release 5.3 (Final)
spencerhudson
Posts: 1
Joined: Mon Oct 25, 2010 4:43 pm

Re: Monitor the iowait in a server

Post by spencerhudson »

You may find as did I that the issue is that the code is stripping out the wrong values. The following code took some time to resolve but gets the correct values

Code: Select all

vmstat 1 16|tail -n 15| awk '{n++;user+=$(NF-4);sys+=$(NF-3);idle+=$(NF-2);iowait+=$(NF-1)} END{print "user:"user/n " sys:"sys/n " idle:"idle/n " iowait:"iowait/n}' > /ideasmerchant/vmstat.html
Notice that i've referenced different values for NF ... what seems to happen is that on different machiens different columns are returned and you need to map up the ones you need. Below you can see the columns from the vmstat command you need to look at (for my machine anyway).

Code: Select all

[root@ww2 ]# vmstat 1 16
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  3    100  73100 216456 2944144    0    0   138   262   10   10 13  4 37 46  0
 1  3    100  72628 216464 2944144    0    0     0  1176 4380 3314 14  5 35 47  0
 0  3    100  70596 216500 2944144    0    0     0   756 3498 2269  9  2 41 49  0
 0  3    100  76920 216500 2944308    0    0     0   328 2391 1106  7  2 42 50  0
 0  3    100  78292 216504 2944256    0    0     0  1116 2701 1698  8  4 40 47  0
 0  3    100  77432 216504 2944252    0    0     0  1052 2798 1401  4  2 45 50  0
 0  3    100  76812 216504 2944316    0    0     0   456 3059 1964  7  1 42 50  0
 0  3    100  77804 216508 2944320    0    0     8   856 2879 1915  8  3 40 50  0
 0  3    100  72720 216512 2944364    0    0     0   412 3204 2122 11  4 37 47  0
 2  3    100  72612 216520 2944352    0    0     0 10708 5715 2413  5  5 42 48  0
 0  3    100  76936 216532 2944380    0    0     0   496 2024 1113  5  3 44 49  0
 0  3    100  84896 216540 2944376    0    0     0   728 2462 1447  7  3 42 49  0
 1  3    100  98776 216564 2944408    0    0     0  3452 4448 3059 17  4 33 45  0
 0  3    100 106720 216564 2944408    0    0     0     0 1926  765  6  2 46 47  0
 0  3    100 113052 216576 2944460    0    0     0  1168 2025 1052  7  3 44 48  0
 0  3    100 119136 216588 2944456    0    0     0   504 1663  649  3  1 46 49  0
After a little trial an errror i managed to get the code to report the correct outout

Code: Select all

[root@ww2 ]# vmstat 1 16
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  3    100 102524 218636 2955400    0    0   138   262   11   10 13  4 37 46  0
 0  3    100  94332 218636 2955400    0    0     0     0 2870 1634 14  3 38 46  0
 0  3    100  88612 218636 2955444    0    0     0    24 2845 1553  8  2 41 50  0
...
 0  3    100 124496 218648 2955636    0    0     0    12 2043  713  4  2 46 50  0
 0  3    100 121924 218648 2955636    0    0     0     0 2729 1524  8  2 41 49  0
[root@ww2 ]# cat html/app/vmstat.html
user:4.33333 sys:1.46667 idle:44.7333 iowait:49.8667
[root@ww2 ]#
Now I just need to get cacti recording this information and reporting it back as a graph :) Anyone?
spencer hudson
ideasmerchant.com
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests