[Tutor] CPU Utilization

Hugo González Monteverde hugonz-lists at h-lab.net
Wed Jan 11 20:56:47 CET 2006


Hi,

top is very interactive so it would not be easy at all to parse.

I can suggest reading /proc/loadavg if you're in Linux.

proc(5) ('man 5 proc') says that /proc/loadavg is
     The load average numbers give the number of jobs in
     the run queue averaged over 1, 5 and 15 minutes.
     They are the same as the load average numbers given
     by uptime(1) and other programs.

It can be easily parsed with split()

Hope that helps,

Hugo


DS wrote:
> I am implementing a computational cluster and am using a job controller
> (for want of a better term) that contacts the worker computers,
> determines how busy they currently are, and then assigns more work if
> the worker computer is below a certain cpu utilization threshhold. 
> 
> For the cpu threshhold, I've been thinking I'd have the worker computer
> shell out to perform the top command, parse the results, and report
> those values to the job controller.
> 
> Is there a better way, or more pythonic, way to do this?
> 
> Thanks
> 
> ds
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


More information about the Tutor mailing list