browskie browskie - 9 months ago 61
Python Question

Get IO Wait time as % in python

I am writing a python script to get some basic system stats. I am using psutil for most of it and it is working fine except for one thing that I need.

I'd like to log the average cpu wait time at the moment.
from top output it would be in CPU section under %wa.

I can't seem to find how to get that in psutil, does anyone know how to get it? I am about to go down a road I really don't want to go on....

That entire CPU row is rather nice, since it totals to 100 and it is easy to log and plot.

Thanks in advance.

Answer Source

%wa is giving your the iowait of the CPU, and if you are using times = psutil.cpu_times() or times = psutil.cpu_times_percent() then it is under the times.iowait variable of the returned value (Assuming you are on a Linux system)