mirror of
https://github.com/Tafkas/fritzbox-munin.git
synced 2023-10-10 13:36:55 +02:00
make checks language agnostic. Rely on position instead.
This commit is contained in:
parent
883c61e498
commit
2dd4e07013
@ -33,8 +33,8 @@ def get_memory_usage():
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
for usage in enumerate(USAGE):
|
||||
print('%s.value %s' % (usage[1], data['data']['ramusage']['series'][usage[0]][-1]))
|
||||
for i, usage in enumerate(USAGE):
|
||||
print('%s.value %s' % (usage, data['data']['ramusage']['series'][i][-1]))
|
||||
|
||||
|
||||
def print_config():
|
||||
|
@ -23,12 +23,7 @@ import sys
|
||||
import fritzbox_helper as fh
|
||||
|
||||
PAGE = 'energy'
|
||||
DEVICES = {'FRITZ!Box Gesamtsystem': 'system',
|
||||
'FRITZ!Box Hauptprozessor': 'cpu',
|
||||
'WLAN': 'wifi',
|
||||
'DSL': 'dsl',
|
||||
'analoge FON-Anschlüsse': 'ab',
|
||||
'USB-Geräte': 'usb'}
|
||||
DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
|
||||
|
||||
|
||||
def get_power_consumption():
|
||||
@ -40,11 +35,9 @@ def get_power_consumption():
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
for d in data['data']['drain']:
|
||||
try:
|
||||
print('%s.value %s' % (DEVICES[d['name']], d['actPerc']))
|
||||
except KeyError as e:
|
||||
pass
|
||||
devices = data['data']['drain']
|
||||
for i, device in enumerate(DEVICES):
|
||||
print('%s.value %s' % (device, devices[i]['actPerc']))
|
||||
|
||||
|
||||
def print_config():
|
||||
|
@ -39,12 +39,10 @@ def get_connected_wifi_devices():
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
for d in data['data']['drain']:
|
||||
if d['name'] == 'WLAN':
|
||||
m = re.search(pattern, d['statuses'][-1])
|
||||
if m:
|
||||
connected_devices = int(m.group(1))
|
||||
print('wifi.value %d' % connected_devices)
|
||||
m = re.search(pattern, data['data']['drain'][2]['statuses'][-1])
|
||||
if m:
|
||||
connected_devices = int(m.group(1))
|
||||
print('wifi.value %d' % connected_devices)
|
||||
|
||||
|
||||
def print_config():
|
||||
|
Loading…
Reference in New Issue
Block a user