Rumah > Soal Jawab > teks badan
大家讲道理2017-04-17 17:07:32
import re
def getProcesses(usage=80.0, filename='performance.txt'):
with open(filename) as f:
lines = f.readlines()
for line in lines:
m = re.search('^\d+.*\s+(\d+\.\d+)\s+(\d+\.\d+).*\:', line)
if m:
cpu_usage = m.group(1)
if float(cpu_usage) > usage:
print "CPU: ", cpu_usage
print line
getProcesses()