|
65 | 65 | # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
|
66 | 66 | cmd = "hostname -I | cut -d' ' -f1"
|
67 | 67 | IP = subprocess.check_output(cmd, shell=True).decode("utf-8")
|
68 |
| - cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'" |
| 68 | + cmd = 'cut -f 1 -d " " /proc/loadavg' |
69 | 69 | CPU = subprocess.check_output(cmd, shell=True).decode("utf-8")
|
70 | 70 | cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB %.2f%%\", $3,$2,$3*100/$2 }'"
|
71 | 71 | MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8")
|
|
75 | 75 | # Write four lines of text.
|
76 | 76 |
|
77 | 77 | draw.text((x, top + 0), "IP: " + IP, font=font, fill=255)
|
78 |
| - draw.text((x, top + 8), CPU, font=font, fill=255) |
| 78 | + draw.text((x, top + 8), "CPU load: " + CPU, font=font, fill=255) |
79 | 79 | draw.text((x, top + 16), MemUsage, font=font, fill=255)
|
80 | 80 | draw.text((x, top + 25), Disk, font=font, fill=255)
|
81 | 81 |
|
|
0 commit comments