mirror of
https://github.com/Tafkas/fritzbox-munin.git
synced 2023-10-10 11:36:55 +00:00
Merge fabad1fdd51a39617f21894c2e592f8cda5bfcc7 into eee98feeacb0266e31a509cbb34abaa6c2a5f12c
This commit is contained in:
commit
24934ec839
@ -85,7 +85,8 @@ If you are using the scripts on a different Fritz!Box model please let me know b
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip <ip_address_to_your_fritzbox>
|
||||
env.fritzbox_password <fritzbox_password>
|
||||
env.FRITZ_USERNAME <optional: fritzbox username>
|
||||
env.FRITZ_PASSWORD <FRITZ_PASSWORD>
|
||||
env.traffic_remove_max true # if you do not want the possible max values
|
||||
host_name fritzbox
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
fritzbox_connection_uptime - A munin plugin for Linux to monitor AVM Fritzbox connection uptime
|
||||
Copyright (C) 2015 Christian Stade-Schuldt
|
||||
@ -22,15 +22,19 @@ from fritzconnection import FritzConnection
|
||||
|
||||
def print_values():
|
||||
try:
|
||||
conn = FritzConnection(address=os.environ['fritzbox_ip'])
|
||||
conn = FritzConnection(address=os.getenv('fritzbox_ip'))
|
||||
except Exception as e:
|
||||
sys.exit("Couldn't get connection uptime")
|
||||
sys.exit(f"Couldn't get connection uptime: {e}")
|
||||
|
||||
uptime = conn.call_action('WANIPConnection', 'GetStatusInfo')['NewUptime']
|
||||
print('uptime.value %.2f' % (int(uptime) / 86400.0))
|
||||
|
||||
|
||||
def print_config():
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print("graph_title Connection Uptime")
|
||||
else:
|
||||
print("graph_title AVM Fritz!Box Connection Uptime")
|
||||
print("graph_args --base 1000 -l 0")
|
||||
print('graph_vlabel uptime in days')
|
||||
@ -38,8 +42,6 @@ def print_config():
|
||||
print("graph_category network")
|
||||
print("uptime.label uptime")
|
||||
print("uptime.draw AREA")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -50,5 +52,5 @@ if __name__ == "__main__":
|
||||
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
||||
try:
|
||||
print_values()
|
||||
except:
|
||||
sys.exit("Couldn't retrieve fritzbox connection uptime")
|
||||
except Exception as e:
|
||||
sys.exit(f"Couldn't retrieve fritzbox connection uptime: {e}")
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
fritzbox_cpu_temperature - A munin plugin for Linux to monitor AVM Fritzbox
|
||||
Copyright (C) 2015 Christian Stade-Schuldt
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip [ip address of the fritzbox]
|
||||
env.fritzbox_password [fritzbox password]
|
||||
env.FRITZ_PASSWORD [fritzbox password]
|
||||
env.FRITZ_USERNAME [optional: fritzbox username]
|
||||
|
||||
This plugin supports the following munin configuration parameters:
|
||||
#%# family=auto contrib
|
||||
@ -26,17 +27,25 @@ PAGE = 'ecoStat'
|
||||
def get_cpu_temperature():
|
||||
"""get the current cpu temperature"""
|
||||
|
||||
server = os.environ['fritzbox_ip']
|
||||
password = os.environ['fritzbox_password']
|
||||
server = os.getenv('fritzbox_ip')
|
||||
password = os.getenv('FRITZ_PASSWORD')
|
||||
|
||||
session_id = fh.get_session_id(server, password)
|
||||
if "FRITZ_USERNAME" in os.environ:
|
||||
fritzuser = os.getenv('FRITZ_USERNAME')
|
||||
session_id = fh.get_session_id(server, password, fritzuser)
|
||||
else:
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
print('temp.value %d' % (int(data['data']['cputemp']['series'][0][-1])))
|
||||
|
||||
|
||||
def print_config():
|
||||
print("graph_title AVM Fritz!Box CPU temperature")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print("graph_title Temperatures")
|
||||
else:
|
||||
print("graph_title AVM Fritz!Box CPU temperature")
|
||||
print("graph_vlabel degrees Celsius")
|
||||
print("graph_category sensors")
|
||||
print("graph_order tmp")
|
||||
@ -46,8 +55,6 @@ def print_config():
|
||||
print("temp.graph LINE1")
|
||||
print("temp.min 0")
|
||||
print("temp.info Fritzbox CPU temperature")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
fritzbox_cpu_usage - A munin plugin for Linux to monitor AVM Fritzbox
|
||||
Copyright (C) 2015 Christian Stade-Schuldt
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip [ip address of the fritzbox]
|
||||
env.fritzbox_password [fritzbox password]
|
||||
env.FRITZ_PASSWORD [fritzbox password]
|
||||
env.FRITZ_USERNAME [optional: fritzbox username]
|
||||
|
||||
This plugin supports the following munin configuration parameters:
|
||||
#%# family=auto contrib
|
||||
@ -26,17 +27,25 @@ PAGE = 'ecoStat'
|
||||
def get_cpu_usage():
|
||||
"""get the current cpu usage"""
|
||||
|
||||
server = os.environ['fritzbox_ip']
|
||||
password = os.environ['fritzbox_password']
|
||||
server = os.getenv('fritzbox_ip')
|
||||
password = os.getenv('FRITZ_PASSWORD')
|
||||
|
||||
session_id = fh.get_session_id(server, password)
|
||||
if "FRITZ_USERNAME" in os.environ:
|
||||
fritzuser = os.getenv('FRITZ_USERNAME')
|
||||
session_id = fh.get_session_id(server, password, fritzuser)
|
||||
else:
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
print('cpu.value %d' % (int(data['data']['cpuutil']['series'][0][-1])))
|
||||
|
||||
|
||||
def print_config():
|
||||
print("graph_title AVM Fritz!Box CPU usage")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print("graph_title CPU usage")
|
||||
else :
|
||||
print("graph_title AVM Fritz!Box CPU usage")
|
||||
print("graph_vlabel %")
|
||||
print("graph_category system")
|
||||
print("graph_order cpu")
|
||||
@ -46,8 +55,6 @@ def print_config():
|
||||
print("cpu.graph AREA")
|
||||
print("cpu.min 0")
|
||||
print("cpu.info Fritzbox CPU usage")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -59,5 +66,5 @@ if __name__ == '__main__':
|
||||
# Some docs say it'll be called with fetch, some say no arg at all
|
||||
try:
|
||||
get_cpu_usage()
|
||||
except:
|
||||
sys.exit("Couldn't retrieve fritzbox cpu usage")
|
||||
except Exception as e:
|
||||
sys.exit(f"Couldn't retrieve fritzbox cpu usage: {e}")
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip [ip address of the fritzbox]
|
||||
env.fritzbox_password [fritzbox password]
|
||||
env.FRITZ_PASSWORD [fritzbox password]
|
||||
env.FRITZ_USERNAME [optional: fritzbox username]
|
||||
|
||||
This plugin supports the following munin configuration parameters:
|
||||
#%# family=auto contrib
|
||||
@ -29,22 +30,25 @@ from lxml import etree
|
||||
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0"
|
||||
|
||||
|
||||
def get_session_id(server, password, port=80):
|
||||
def get_session_id(server, password, username=None, port=80):
|
||||
"""Obtains the session id after login into the Fritzbox.
|
||||
See https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_Technical_Note_-_Session_ID.pdf
|
||||
for deteils (in German).
|
||||
|
||||
:param server: the ip address of the Fritzbox
|
||||
:param password: the password to log into the Fritzbox webinterface
|
||||
:param username: (optional) the username with which to log into the Fritzbox webinterface
|
||||
:param port: the port the Fritzbox webserver runs on
|
||||
:return: the session id
|
||||
"""
|
||||
|
||||
userpar = '' if username is None else '?username={}'.format(username)
|
||||
|
||||
headers = {"Accept": "application/xml",
|
||||
"Content-Type": "text/plain",
|
||||
"User-Agent": USER_AGENT}
|
||||
|
||||
url = 'http://{}:{}/login_sid.lua'.format(server, port)
|
||||
url = 'http://{}:{}/login_sid.lua{}'.format(server, port, userpar)
|
||||
try:
|
||||
r = requests.get(url, headers=headers)
|
||||
r.raise_for_status()
|
||||
@ -67,7 +71,7 @@ def get_session_id(server, password, port=80):
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"User-Agent": USER_AGENT}
|
||||
|
||||
url = 'http://{}:{}/login_sid.lua?&response={}'.format(server, port, response_bf)
|
||||
url = 'http://{}:{}/login_sid.lua?{}&response={}'.format(server, port, userpar[1:], response_bf)
|
||||
try:
|
||||
r = requests.get(url, headers=headers)
|
||||
r.raise_for_status()
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
fritzbox_memory_usage - A munin plugin for Linux to monitor AVM Fritzbox
|
||||
Copyright (C) 2015 Christian Stade-Schuldt
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip [ip address of the fritzbox]
|
||||
env.fritzbox_password [fritzbox password]
|
||||
env.FRITZ_PASSWORD [fritzbox password]
|
||||
env.FRITZ_USERNAME [optional: fritzbox username]
|
||||
|
||||
This plugin supports the following munin configuration parameters:
|
||||
#%# family=auto contrib
|
||||
@ -27,10 +28,14 @@ USAGE = ['strict', 'cache', 'free']
|
||||
def get_memory_usage():
|
||||
"""get the current memory usage"""
|
||||
|
||||
server = os.environ['fritzbox_ip']
|
||||
password = os.environ['fritzbox_password']
|
||||
server = os.getenv('fritzbox_ip')
|
||||
password = os.getenv('FRITZ_PASSWORD')
|
||||
|
||||
session_id = fh.get_session_id(server, password)
|
||||
if "FRITZ_USERNAME" in os.environ:
|
||||
fritzuser = os.getenv('FRITZ_USERNAME')
|
||||
session_id = fh.get_session_id(server, password, fritzuser)
|
||||
else:
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
for i, usage in enumerate(USAGE):
|
||||
@ -38,7 +43,11 @@ def get_memory_usage():
|
||||
|
||||
|
||||
def print_config():
|
||||
print("graph_title AVM Fritz!Box Memory")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print("graph_title Memory usage in percent")
|
||||
else:
|
||||
print("graph_title AVM Fritz!Box Memory")
|
||||
print("graph_vlabel %")
|
||||
print("graph_args --base 1000 -r --lower-limit 0 --upper-limit 100")
|
||||
print("graph_category system")
|
||||
@ -54,8 +63,6 @@ def print_config():
|
||||
print("free.label free")
|
||||
print("free.type GAUGE")
|
||||
print("free.draw STACK")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -67,5 +74,5 @@ if __name__ == '__main__':
|
||||
# Some docs say it'll be called with fetch, some say no arg at all
|
||||
try:
|
||||
get_memory_usage()
|
||||
except:
|
||||
sys.exit("Couldn't retrieve fritzbox memory usage")
|
||||
except Exception as e:
|
||||
sys.exit(f"Couldn't retrieve fritzbox memory usage: {e}")
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# coding=utf-8
|
||||
"""
|
||||
fritzbox_power_consumption - A munin plugin for Linux to monitor AVM Fritzbox
|
||||
@ -10,7 +10,8 @@
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip [ip address of the fritzbox]
|
||||
env.fritzbox_password [fritzbox password]
|
||||
env.FRITZ_PASSWORD [fritzbox password]
|
||||
env.FRITZ_USERNAME [optional: fritzbox username]
|
||||
|
||||
This plugin supports the following munin configuration parameters:
|
||||
#%# family=auto contrib
|
||||
@ -29,10 +30,14 @@ DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
|
||||
def get_power_consumption():
|
||||
"""get the current power consumption usage"""
|
||||
|
||||
server = os.environ['fritzbox_ip']
|
||||
password = os.environ['fritzbox_password']
|
||||
server = os.getenv('fritzbox_ip')
|
||||
password = os.getenv('FRITZ_PASSWORD')
|
||||
|
||||
session_id = fh.get_session_id(server, password)
|
||||
if "FRITZ_USERNAME" in os.environ:
|
||||
fritzuser = os.getenv('FRITZ_USERNAME')
|
||||
session_id = fh.get_session_id(server, password, fritzuser)
|
||||
else:
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
devices = data['data']['drain']
|
||||
@ -41,9 +46,13 @@ def get_power_consumption():
|
||||
|
||||
|
||||
def print_config():
|
||||
print("graph_title AVM Fritz!Box Power Consumption")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print("graph_title Power consumption")
|
||||
else:
|
||||
print("graph_title AVM Fritz!Box Power Consumption")
|
||||
print("graph_vlabel %")
|
||||
print("graph_category system")
|
||||
print("graph_category sensors")
|
||||
print("graph_order system cpu wifi dsl ab usb")
|
||||
print("system.label system")
|
||||
print("system.type GAUGE")
|
||||
@ -81,8 +90,6 @@ def print_config():
|
||||
print("usb.min 0")
|
||||
print("usb.max 100")
|
||||
print("usb.info Fritzbox usb devices power consumption")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -94,5 +101,5 @@ if __name__ == '__main__':
|
||||
# Some docs say it'll be called with fetch, some say no arg at all
|
||||
try:
|
||||
get_power_consumption()
|
||||
except:
|
||||
sys.exit("Couldn't retrieve fritzbox power consumption")
|
||||
except Exception as e:
|
||||
sys.exit(f"Couldn't retrieve fritzbox power consumption: {e}")
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
fritzbox_traffic - A munin plugin for Linux to monitor AVM Fritzbox WAN traffic
|
||||
Copyright (C) 2015 Christian Stade-Schuldt
|
||||
@ -22,9 +22,9 @@ from fritzconnection import FritzConnection
|
||||
|
||||
def print_values():
|
||||
try:
|
||||
conn = FritzConnection(address=os.environ['fritzbox_ip'])
|
||||
conn = FritzConnection(address=os.getenv('fritzbox_ip'))
|
||||
except Exception as e:
|
||||
sys.exit("Couldn't get WAN traffic")
|
||||
sys.exit(f"Couldn't get WAN traffic: {e}")
|
||||
|
||||
down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesReceived')['NewTotalBytesReceived']
|
||||
print('down.value %d' % down_traffic)
|
||||
@ -43,7 +43,11 @@ def print_values():
|
||||
|
||||
|
||||
def print_config():
|
||||
print("graph_title AVM Fritz!Box WAN traffic")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print("graph_title Uplink traffic")
|
||||
else:
|
||||
print("graph_title AVM Fritz!Box WAN traffic")
|
||||
print("graph_args --base 1000")
|
||||
print("graph_vlabel bits in (-) / out (+) per \${graph_period}")
|
||||
print("graph_category network")
|
||||
@ -56,7 +60,7 @@ def print_config():
|
||||
print("down.max 1000000000")
|
||||
print("up.label bps")
|
||||
print("up.type DERIVE")
|
||||
print("up.draw AREA")
|
||||
print("up.draw LINE")
|
||||
print("up.cdef up,8,*")
|
||||
print("up.min 0")
|
||||
print("up.max 1000000000")
|
||||
@ -71,8 +75,6 @@ def print_config():
|
||||
print("maxup.negative maxdown")
|
||||
print("maxup.draw LINE1")
|
||||
print("maxup.info Maximum speed of the WAN interface.")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -83,5 +85,5 @@ if __name__ == "__main__":
|
||||
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
||||
try:
|
||||
print_values()
|
||||
except:
|
||||
sys.exit("Couldn't retrieve fritzbox traffic")
|
||||
except Exception as e:
|
||||
sys.exit(f"Couldn't retrieve fritzbox traffic: {e}")
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
fritzbox_uptime - A munin plugin for Linux to monitor AVM Fritzbox
|
||||
Copyright (C) 2015 Christian Stade-Schuldt
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip [ip address of the fritzbox]
|
||||
env.fritzbox_password [fritzbox password]
|
||||
env.FRITZ_PASSWORD [fritzbox password]
|
||||
env.FRITZ_USERNAME [optional: fritzbox username]
|
||||
|
||||
This plugin supports the following munin configuration parameters:
|
||||
#%# family=auto contrib
|
||||
@ -36,10 +37,14 @@ pattern = re.compile(patternLoc[locale])
|
||||
def get_uptime():
|
||||
"""get the current uptime"""
|
||||
|
||||
server = os.environ['fritzbox_ip']
|
||||
password = os.environ['fritzbox_password']
|
||||
server = os.getenv('fritzbox_ip')
|
||||
password = os.getenv('FRITZ_PASSWORD')
|
||||
|
||||
session_id = fh.get_session_id(server, password)
|
||||
if "FRITZ_USERNAME" in os.environ:
|
||||
fritzuser = os.getenv('FRITZ_USERNAME')
|
||||
session_id = fh.get_session_id(server, password, fritzuser)
|
||||
else:
|
||||
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']:
|
||||
@ -59,15 +64,17 @@ def get_uptime():
|
||||
|
||||
|
||||
def print_config():
|
||||
print("graph_title AVM Fritz!Box Uptime")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print("graph_title Uptime")
|
||||
else:
|
||||
print("graph_title AVM Fritz!Box Uptime")
|
||||
print("graph_args --base 1000 -l 0")
|
||||
print('graph_vlabel uptime in days')
|
||||
print("graph_scale no'")
|
||||
print("graph_category system")
|
||||
print("uptime.label uptime")
|
||||
print("uptime.draw AREA")
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -79,5 +86,5 @@ if __name__ == '__main__':
|
||||
# Some docs say it'll be called with fetch, some say no arg at all
|
||||
try:
|
||||
get_uptime()
|
||||
except:
|
||||
sys.exit("Couldn't retrieve fritzbox uptime")
|
||||
except Exception as e:
|
||||
sys.exit(f"Couldn't retrieve fritzbox uptime; {e}")
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
fritzbox_wifi_devices - A munin plugin for Linux to monitor AVM Fritzbox
|
||||
Copyright (C) 2015 Christian Stade-Schuldt
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
[fritzbox_*]
|
||||
env.fritzbox_ip [ip address of the fritzbox]
|
||||
env.fritzbox_password [fritzbox password]
|
||||
env.FRITZ_PASSWORD [fritzbox password]
|
||||
env.FRITZ_USERNAME [optional: fritzbox username]
|
||||
|
||||
This plugin supports the following munin configuration parameters:
|
||||
#%# family=auto contrib
|
||||
@ -31,12 +32,16 @@ pattern = re.compile(patternLoc[locale])
|
||||
|
||||
|
||||
def get_connected_wifi_devices():
|
||||
"""gets the numbrer of currently connected wifi devices"""
|
||||
"""gets the numbrer of currently connected wi-fi devices"""
|
||||
|
||||
server = os.environ['fritzbox_ip']
|
||||
password = os.environ['fritzbox_password']
|
||||
server = os.getenv('fritzbox_ip')
|
||||
password = os.getenv('FRITZ_PASSWORD')
|
||||
|
||||
session_id = fh.get_session_id(server, password)
|
||||
if "FRITZ_USERNAME" in os.environ:
|
||||
fritzuser = os.getenv('FRITZ_USERNAME')
|
||||
session_id = fh.get_session_id(server, password, fritzuser)
|
||||
else:
|
||||
session_id = fh.get_session_id(server, password)
|
||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||
data = json.loads(xhr_data)
|
||||
m = re.search(pattern, data['data']['drain'][2]['statuses'][-1])
|
||||
@ -46,7 +51,11 @@ def get_connected_wifi_devices():
|
||||
|
||||
|
||||
def print_config():
|
||||
print('graph_title AVM Fritz!Box Connected Wifi Devices')
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.getenv('host_name'))
|
||||
print('graph_title Connected Wi-Fi Devices')
|
||||
else:
|
||||
print('graph_title AVM Fritz!Box Connected Wi-Fi Devices')
|
||||
print('graph_vlabel Number of devices')
|
||||
print('graph_args --base 1000')
|
||||
print('graph_category network')
|
||||
@ -55,8 +64,6 @@ def print_config():
|
||||
print('wifi.type GAUGE')
|
||||
print('wifi.graph LINE1')
|
||||
print('wifi.info Wifi Connections on 2.4 & 5 Ghz')
|
||||
if os.environ.get('host_name'):
|
||||
print("host_name " + os.environ['host_name'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -68,5 +75,5 @@ if __name__ == '__main__':
|
||||
# Some docs say it'll be called with fetch, some say no arg at all
|
||||
try:
|
||||
get_connected_wifi_devices()
|
||||
except:
|
||||
sys.exit("Couldn't retrieve connected fritzbox wifi devices")
|
||||
except Exception as e:
|
||||
sys.exit(f"Couldn't retrieve connected fritzbox wifi devices: {e}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user