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()
Put the serial number and processed text into a tuple, then store the tuple in a list, and then arrange it according to the serial number in the tuple. Try it?
Put the serial number and processed text into a tuple, then store the tuple in a list, and then arrange it according to the serial number in the tuple.
Try it?
import psutil
imoprt Dafa is good