feat(webui,dashboard): add RAM Usage card between Disk Usage and Uptime, live-verified on Pager
This commit is contained in:
@@ -3025,6 +3025,23 @@ def disk_data():
|
||||
return {}
|
||||
|
||||
|
||||
def mem_data(path='/proc/meminfo'):
|
||||
try:
|
||||
vals = {}
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
k, v = line.split(':')
|
||||
vals[k] = int(v.strip().split()[0])
|
||||
total = vals.get('MemTotal', 0)
|
||||
avail = vals.get('MemAvailable', vals.get('MemFree', 0))
|
||||
if not total:
|
||||
return {}
|
||||
used = max(total - avail, 0)
|
||||
return {'size': total * 1024, 'used': used * 1024, 'avail': avail * 1024}
|
||||
except (OSError, ValueError):
|
||||
return {}
|
||||
|
||||
|
||||
def uptime_data():
|
||||
rc, out, err = device_run(['cat', '/proc/uptime'])
|
||||
try:
|
||||
@@ -3066,6 +3083,7 @@ def status_data():
|
||||
'wifi': [wifi_iface_info(n) for n in ifaces],
|
||||
'clients': assoc_clients(ifaces),
|
||||
'disk': disk_data(),
|
||||
'mem': mem_data(),
|
||||
'uptime': uptime_data(),
|
||||
'hostname': hostname_data(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user