I am trying to set up some system monitoring. I want to calculate the percentage of time the disk is processing read or write requests. I am try to do this with psutil. My current solution looks like this:
readtime = (psutil.disk_io_counters().read_time / 1000) / 1000
writetime = (psutil.disk_io_counters().write_time / 1000) / 1000
busytime = readtime + writetime;
percentage = (busytime) / 60
print(percentage)
The double divide by 1000 is because I read somewhere that read_time
returns nano seconds. My issue is this solution only ever return 4% even when I run a disk defragmentation and disk % is at 100 it returns 4%. I must be misunderstanding what read_time
and write_time
are used for. Does anyone know what I am doing wrong or have an alternative solution? I am currently testing this on Windows 10 environment.