Thanks for your responses. Michael Janssen wrote:
>It's perhaps easier to read the information from the /proc filesystem >(this is where top gets it itself). "man proc" tells where the info is >stored (guess: /proc/stat). > > > stat does look in some ways easier. I will say that I found the statistics somewhat baffling, but I'm sure it's all there. Hugo González Monteverde wrote: >Hi, > >top is very interactive so it would not be easy at all to parse. > > > Actually top has a batch mode. This works pretty well. *def* xmlrpc_idlecpu(self): u = commands.getoutput('top -b -n 1') *return* u.split('\n')[2].split(',')[3] >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() > > That's an interesting idea to use that. Although if you have big jobs and little jobs you might not know whether you can add another job to that computer or not, because you would necessarily be attempting to derive the utilization from those statistics. Thank you both for your answers. ds _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor