Closed DougieLawson closed 8 years ago
Putting that all together I came up with this diff file
--- sys_info.py 2015-12-28 17:39:50.348930030 +0000
+++ sys_info.py~ 2015-12-28 17:22:28.391519969 +0000
@@ -36,13 +36,13 @@
def cpu_usage():
# load average, uptime
- uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time())
+ uptime = datetime.now() - datetime.fromtimestamp(psutil.BOOT_TIME)
av1, av2, av3 = os.getloadavg()
return "Load:%.1f %.1f %.1f Up: %s" \
% (av1, av2, av3, str(uptime).split('.')[0])
def mem_usage():
- usage = psutil.virtual_memory()
+ usage = psutil.phymem_usage()
return "Mem: %s %.0f%%" \
% (bytes2human(usage.used), 100 - usage.percent)
@@ -53,7 +53,7 @@
% (bytes2human(usage.used), usage.percent)
def network(iface):
- stat = psutil.net_io_counters(pernic=True)[iface]
+ stat = psutil.network_io_counters(pernic=True)[iface]
return "%s:Tx%s,Rx%s" % \
(iface, bytes2human(stat.bytes_sent), bytes2human(stat.bytes_recv))
@@ -66,7 +66,7 @@
lcd.locate(0,2)
lcd.text(disk_usage('/'))
lcd.locate(0,3)
- lcd.text(network('eth0'))
+ lcd.text(network('wlan0'))
lcd.locate(0,4)
def main():
Oh nice one, I'll merge it in. This repo hasn't seen much action lately, so I guess the libs have moved on a bit
Beware: that diff file is upside down, because I'm an idiot (unlikely) or the diff util isn't intuitive (more likely).
Thank you. I'll give that a go in the morning.
and
and
It needs to use
It also doesn't work if there's no wlan0 interface. The RPi I'm running on only has eth0. You can use
To determine whether an interface exists.