Spaces:
BG5
/
Running

BG5 commited on
Commit
530e746
·
verified ·
1 Parent(s): 1d0c5da

Update fun.py

Browse files
Files changed (1) hide show
  1. fun.py +4 -5
fun.py CHANGED
@@ -21,11 +21,10 @@ PORT_RANGE = (9300, 9700)
21
  CHROME_PATH = "google-chrome" # Linux下可用命令,或自定义绝对路径
22
  PROFILE_BASE = "/tmp/profiles"
23
  def get_system_usage():
24
- cpu = subprocess.check_output("top -l 1 | grep -E '^CPU'", shell=True)
25
- member = subprocess.check_output("top -l 1 | grep -E '^Phys'", shell=True)
26
- # Linux 可用: free -m
27
- print("系统资源 cpu:", cpu.decode().strip(), "内存:", member.decode().strip())
28
- return f'CPU: {cpu.decode().strip()}\nMemory: {member.decode().strip()}'
29
  def get_free_port():
30
  used_ports = {b["port"] for b in BROWSERS.values()}
31
  for _ in range(100):
 
21
  CHROME_PATH = "google-chrome" # Linux下可用命令,或自定义绝对路径
22
  PROFILE_BASE = "/tmp/profiles"
23
  def get_system_usage():
24
+ cpu = subprocess.check_output("top -bn1 | grep 'Cpu(s)'", shell=True).decode().strip()
25
+ mem = subprocess.check_output("free -m | grep Mem", shell=True).decode().strip()
26
+ print("系统资源 cpu:", cpu, "内存:", mem)
27
+ return f'CPU: {cpu}\nMemory: {mem}'
 
28
  def get_free_port():
29
  used_ports = {b["port"] for b in BROWSERS.values()}
30
  for _ in range(100):