Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass

JeffersGlass/system_monitor.py Secret

Created Aug 30, 2020
Embed
What would you like to do?
from psutil import cpu_percent, net_io_counters
from gpiozero import LEDBarGraph
from time import sleep
graph = LEDBarGraph(12, 21, 20, pwm=True)
#Show CPU occupation percentage
while True:
graph.value = cpu_percent()/100
sleep(.1)
#Show network activitiy
'''
oldBytes = net_io_counters().bytes_sent + net_io_counters().bytes_recv
while True:
newBytes = net_io_counters().bytes_sent + net_io_counters().bytes_recv
diff = newBytes - oldBytes
oldBytes = newBytes
print (newBytes)
graph.value = min(1, max(0, diff / 10000)) #constrain value to 0:1
sleep(.1)
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.