mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:59:25 +08:00
OP防火墙-获取cpu优化
This commit is contained in:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user