私は今これを持っています:
while True:
# Draw a black filled box to clear the image.
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
cmd = "hostname -I | cut -d\' \' -f1"
IP = subprocess.check_output(cmd, shell = True )
cmd = "top -bn1 | grep load | awk '{printf \"CPU: %.2f\", $(NF-2)}'"
CPU = subprocess.check_output(cmd, shell = True )
cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"
MemUsage = subprocess.check_output(cmd, shell = True )
cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"
Disk = subprocess.check_output(cmd, shell = True )
cmd = "vcgencmd measure_temp |cut -f 2 -d '='"
temp = subprocess.check_output(cmd, shell = True )
# Pi Stats Display
draw.text((0, 0), "IP: " + str(IP,'utf-8'), font=font, fill=255)
draw.text((0, 16), str(CPU,'utf-8') + "%", font=font, fill=255)
draw.text((80, 16), str(temp,'utf-8') , font=font, fill=255)
draw.text((0, 32), str(MemUsage,'utf-8'), font=font, fill=255)
draw.text((0, 48), str(Disk,'utf-8'), font=font, fill=255)
- IPがある行に稼働時間を追加したいです。たとえば、IP:127.0.0.1 UP:d / h / mが表示されます。
- MBではなくGB単位でメモリを書き込むにはどうすればよいですか?