Skip to content

Commit aff8c9d

Browse files
authored
Merge pull request #60 from mrouillard/fix-decimal-separator-issue
fixing issue on reading cpu load when decimal separator is not a dot
2 parents 1473957 + 03d5955 commit aff8c9d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/ssd1306_stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
6666
cmd = "hostname -I | cut -d' ' -f1"
6767
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'
6969
CPU = subprocess.check_output(cmd, shell=True).decode("utf-8")
7070
cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB %.2f%%\", $3,$2,$3*100/$2 }'"
7171
MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8")
@@ -75,7 +75,7 @@
7575
# Write four lines of text.
7676

7777
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)
7979
draw.text((x, top + 16), MemUsage, font=font, fill=255)
8080
draw.text((x, top + 25), Disk, font=font, fill=255)
8181

0 commit comments

Comments
 (0)