1
0
mirror of https://github.com/Tafkas/fritzbox-munin.git synced 2023-10-10 11:36:55 +00:00

handle empty or missing fritzbox_username

This commit is contained in:
Christoph Wempe 2017-03-03 00:44:12 +01:00
parent 45da39f4fc
commit f0d43e8168
7 changed files with 10 additions and 7 deletions

View File

@ -33,7 +33,7 @@ def get_cpu_temperature():
"""get the current cpu temperature""" """get the current cpu temperature"""
server = os.environ['fritzbox_ip'] server = os.environ['fritzbox_ip']
username = os.environ['fritzbox_username'] username = os.getenv('fritzbox_username', "None")
password = os.environ['fritzbox_password'] password = os.environ['fritzbox_password']
sid = fh.get_sid(server, username, password) sid = fh.get_sid(server, username, password)

View File

@ -33,7 +33,7 @@ def get_cpu_usage():
"""get the current cpu usage""" """get the current cpu usage"""
server = os.environ['fritzbox_ip'] server = os.environ['fritzbox_ip']
username = os.environ['fritzbox_username'] username = os.getenv('fritzbox_username', "None")
password = os.environ['fritzbox_password'] password = os.environ['fritzbox_password']
sid = fh.get_sid(server, username, password) sid = fh.get_sid(server, username, password)

View File

@ -58,7 +58,10 @@ def get_sid(server, username, password, port=80):
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
"User-Agent": USER_AGENT} "User-Agent": USER_AGENT}
login_page = "/login_sid.lua?username=" + username + "&response=" + response_bf if username == '' or username == 'None':
login_page = "/login_sid.lua?&response=" + response_bf
else:
login_page = "/login_sid.lua?username=" + username + "&response=" + response_bf
conn.request("GET", login_page, '', headers) conn.request("GET", login_page, '', headers)
response = conn.getresponse() response = conn.getresponse()
data = response.read() data = response.read()

View File

@ -34,7 +34,7 @@ def get_memory_usage():
"""get the current memory usage""" """get the current memory usage"""
server = os.environ['fritzbox_ip'] server = os.environ['fritzbox_ip']
username = os.environ['fritzbox_username'] username = os.getenv('fritzbox_username', "None")
password = os.environ['fritzbox_password'] password = os.environ['fritzbox_password']
sid = fh.get_sid(server, username, password) sid = fh.get_sid(server, username, password)

View File

@ -34,7 +34,7 @@ def get_power_consumption():
"""get the current power consumption usage""" """get the current power consumption usage"""
server = os.environ['fritzbox_ip'] server = os.environ['fritzbox_ip']
username = os.environ['fritzbox_username'] username = os.getenv('fritzbox_username', "None")
password = os.environ['fritzbox_password'] password = os.environ['fritzbox_password']
sid = fh.get_sid(server, username, password) sid = fh.get_sid(server, username, password)

View File

@ -33,7 +33,7 @@ def get_uptime():
"""get the current uptime""" """get the current uptime"""
server = os.environ['fritzbox_ip'] server = os.environ['fritzbox_ip']
username = os.environ['fritzbox_username'] username = os.getenv('fritzbox_username', "None")
password = os.environ['fritzbox_password'] password = os.environ['fritzbox_password']
sid = fh.get_sid(server, username, password) sid = fh.get_sid(server, username, password)

View File

@ -33,7 +33,7 @@ def get_connected_wifi_devices():
"""gets the numbrer of currently connected wifi devices""" """gets the numbrer of currently connected wifi devices"""
server = os.environ['fritzbox_ip'] server = os.environ['fritzbox_ip']
username = os.environ['fritzbox_username'] username = os.getenv('fritzbox_username', "None")
password = os.environ['fritzbox_password'] password = os.environ['fritzbox_password']
sid = fh.get_sid(server, username, password) sid = fh.get_sid(server, username, password)