OP防火墙-获取cpu优化
This commit is contained in:
parent
f328354125
commit
af775fc77d
|
|
@ -147,10 +147,14 @@ def removeBgTask():
|
|||
|
||||
|
||||
def getCpuUsed():
|
||||
import psutil
|
||||
used = psutil.cpu_percent(interval=1)
|
||||
path = getServerDir() + "/cpu.info"
|
||||
mw.writeFile(path, str(int(used)))
|
||||
if mw.isAppleSystem():
|
||||
import psutil
|
||||
used = psutil.cpu_percent(interval=1)
|
||||
mw.writeFile(path, str(int(used)))
|
||||
else:
|
||||
data = mw.execShell("top -n1 | fgrep 'Cpu(s)' | awk '{print 100-$8}'")
|
||||
mw.writeFile(path, str(int(data[0])))
|
||||
|
||||
|
||||
def run():
|
||||
|
|
|
|||
Loading…
Reference in New Issue