I am building a Linux, web-based resource monitor.
For now I am looking forward to use:
df
for reading HDD usage status/proc/meminfo
(through cat) for reading RAM statusmpstat
(from sysstat package) for reading CPU usage
While the df
and /proc/meminfo
returns the data almost instantly, mpstat
delays for the interval I specify - with the minimum accepted value being 1 (in seconds).
Is there a real-time CPU usage reader, or is there a way to make mpstat
return "instantly"?
mpstat output:
[psycketom@stone ~]# mpstat -P ALL 1 1
Linux 3.5.4-1-ARCH (stone) 03/05/2013 _x86_64_ (1 CPU)
11:33:15 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
11:33:16 AM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
11:33:16 AM 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
Average: all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
Average: 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
top
not suited to your purposes for some reason?STDOUT
, which I could grep.top
continuously polls.