来自top命令的cpu

时间:2015-03-24 13:48:14

标签: python multithreading get subprocess cpu

您好我想继续获取CPU信息,但我只能使用此代码获取一个如何修复它?

import subprocess
import time 
while 1:
       top = subprocess.Popen(['top','-b','n1'],stdout = subprocess.PIPE)
       grep = subprocess.Popen(['grep','-i','Cpu(s)'] stdin = top.stdout, stdout = subprocess.PIPE , stderr = subprocess.STDOUT)
       cut = subprocess.Popen(['cut','-c','-13'] , stdin = grep.stdout , stdout = subprocess.PIPE)
       print output
       time.sleep(3)

0 个答案:

没有答案