I have solved it myself, so thought I should share for anybody else interested:
This is my updated graph.py file
class GraphStorageSpace(MenuOption):
"""
How much storage space is left on the external HDD.
"""
def __init__(self):
self.last = self.millis()
MenuOption.__init__(self)
def get_space(self):
show_dl_raw = ""
show_st_sp = "df -h /PATH/TO/NAS/HERE | grep G | cut -d' ' -f5"
hr_dl = run_cmd(show_st_sp)
return hr_dl
def get_storage(self):
show_dl_raw = ""
show_dl_hr = "df -h /PATH/TO/NAS/HERE | grep G | cut -d' ' -f7"
hr_dl = run_cmd(show_dl_hr)
return hr_dl
def redraw(self, menu):
now = self.millis()
if now - self.last < 1000:
return false
menu.write_row(0,'NAS Storage')
menu.write_row(2,str('Free:' + self.get_storage())[:-1])
menu.write_row(1,str('Used:' + self.get_space())[:-1])
I have update the menu.py and renamed it sys-monitor.py and it looks like this:
#!/usr/bin/env python
import dot3k.joystick as joystick
import dot3k.lcd as lcd
import dot3k.backlight as backlight
from dot3k.menu import Menu, MenuOption
from plugins.utils import Backlight, Contrast
from plugins.graph import IPAddress, GraphTemp, GraphCPU, GraphNetSpeed, GraphNetTrans, GraphStorageSpace, GraphSysReboot, GraphSysShutdown
from plugins.clock import Clock
from plugins.wlan import Wlan
import time
"""
Using a set of nested lists you can describe
the menu you want to display on dot3k.
Instances of classes derived from MenuOption can
be used as menu items to show information or change settings.
See GraphTemp, GraphCPU, Contrast and Backlight for examples.
"""
menu = Menu({
'Data':GraphNetTrans(),
'Speed':GraphNetSpeed(),
'IP':IPAddress(),
'CPU':GraphCPU(),
'Temp':GraphTemp(),
'Storage':GraphStorageSpace(),
'Settings': {
'Maintenance': {
'Reboot':GraphSysReboot(),
'Shutdown':GraphSysShutdown(),
'Contrast':Contrast(lcd),
'Backlight':Backlight(backlight)
}
}
},
lcd,
30)
"""
You can use anything to control dot3k.menu,
but you'll probably want to use dot3k.joystick
"""
REPEAT_DELAY = 0.5
@joystick.on(joystick.UP)
def handle_up(pin):
menu.up()
joystick.repeat(joystick.UP,menu.up,REPEAT_DELAY,0.9)
@joystick.on(joystick.DOWN)
def handle_down(pin):
menu.down()
joystick.repeat(joystick.DOWN,menu.down,REPEAT_DELAY,0.9)
@joystick.on(joystick.LEFT)
def handle_left(pin):
menu.left()
joystick.repeat(joystick.LEFT,menu.left,REPEAT_DELAY,0.9)
@joystick.on(joystick.RIGHT)
def handle_right(pin):
menu.right()
joystick.repeat(joystick.RIGHT,menu.right,REPEAT_DELAY,0.9)
@joystick.on(joystick.BUTTON)
def handle_button(pin):
menu.select()
while 1:
menu.redraw()
time.sleep(0.05)
I am now able to see various stats on my headless Pi including:
- Storage space
- Data transmission
- Download / Upload Speed
- CPU utilisation
- Temperature
- IP Address
I am also able to reboot and shutdown the Pi using the DOT3K too.
Now off to feel smug about doing something myself for once!! :)