![메모리 사용량, 디스크 사용량, CPU 로드 및 가동 시간을 표시하는 명령](https://linux55.com/image/199169/%EB%A9%94%EB%AA%A8%EB%A6%AC%20%EC%82%AC%EC%9A%A9%EB%9F%89%2C%20%EB%94%94%EC%8A%A4%ED%81%AC%20%EC%82%AC%EC%9A%A9%EB%9F%89%2C%20CPU%20%EB%A1%9C%EB%93%9C%20%EB%B0%8F%20%EA%B0%80%EB%8F%99%20%EC%8B%9C%EA%B0%84%EC%9D%84%20%ED%91%9C%EC%8B%9C%ED%95%98%EB%8A%94%20%EB%AA%85%EB%A0%B9.png)
나는 지금 이것을 가지고 있습니다 :
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 단위로 메모리를 기록하려면 어떻게 해야 합니까?