Made the memtemp plugin usable and added to default.yml

Signed-off-by: spees <speeskonijn@gmail.com>
This commit is contained in:
spees 2019-10-17 23:55:11 +02:00
parent 299bd9a5ca
commit 0aa4f95235
2 changed files with 22 additions and 8 deletions

View File

@ -74,6 +74,8 @@ main:
netmask: 24
interval: 1 # check every x minutes for device
share_internet: false
memtemp: # Display memory usage and cpu temperature on screen
enabled: false
# monitor interface to use
iface: mon0
# command to run to bring the mon interface up in case it's not up already

View File

@ -2,8 +2,19 @@
#
# totalmem usedmem freemem cputemp
#
###############################################################
#
# Updated 18-10-2019 by spees <speeskonijn@gmail.com>
# - Changed the place where the data was displayed on screen
# - Made the data a bit more compact and easier to read
# - removed the label so we wont waste screen space
# - Updated version to 1.0.1
#
###############################################################
__author__ = 'https://github.com/xenDE'
__version__ = '1.0.0'
__version__ = '1.0.1'
__name__ = 'memtemp'
__license__ = 'GPL3'
__description__ = 'A plugin that will add a memory and temperature indicator'
@ -21,9 +32,9 @@ class MEMTEMP:
# set the minimum seconds before refresh the values
refresh_wait = 30
refresh_ts_last = time.time() - refresh_wait
def __init__(self):
# only import when the module is loaded and enabled
import os
@ -31,9 +42,9 @@ class MEMTEMP:
def get_temp(self):
try:
temp = os.popen('/opt/vc/bin/vcgencmd measure_temp').readlines()[0].split('=')[1].replace("\n", '').replace("'","")
return 'cpu:' + temp
return 't:' + temp
except:
return 'cpu:0.0C'
return 't:-'
# cpu:37.4C
def get_mem_info(self):
@ -42,9 +53,9 @@ class MEMTEMP:
# total, used, free = map(int, os.popen('free -t -m').readlines()[-1].split()[1:])
# without Swap, only real memory:
total, used, free = map(int, os.popen('free -t -m').readlines()[-3].split()[1:4])
return "tm:"+str(total)+" um:"+str(used)+" fm:"+str(free)
return "\nT:"+str(total)+"M U:"+str(used)+"M\nF:"+str(free)+"M"
except:
return "tm:0 um:0 fm:0"
return "\nT:- U:-\nF:- "
# tm:532 um:82 fm:353
@ -57,7 +68,7 @@ def on_loaded():
def on_ui_setup(ui):
ui.add_element('memtemp', LabeledValue(color=BLACK, label='SYS', value='tm:0 um:0 fm:0 0.0C', position=(0, ui.height()-28),
ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='\nT:- U:-\nF:- -', position=(ui.width() / 2 + 17, ui.height() / 2),
label_font=fonts.Bold, text_font=fonts.Medium))
@ -66,3 +77,4 @@ def on_ui_update(ui):
ui.set('memtemp', "%s %s" % (memtemp.get_mem_info(), memtemp.get_temp()))
memtemp.refresh_ts_last = time.time()