mirror of
https://github.com/Tafkas/fritzbox-munin.git
synced 2023-10-10 13:36:55 +02:00
use username and password
This commit is contained in:
parent
eee98feeac
commit
485846a780
15
README.md
15
README.md
@ -15,6 +15,8 @@ If you are using the scripts on a different Fritz!Box model please let me know b
|
|||||||
- [FRITZ!Box 7390](http://geni.us/BlAP)
|
- [FRITZ!Box 7390](http://geni.us/BlAP)
|
||||||
- [FRITZ!Box 7430](http://geni.us/BlAP)
|
- [FRITZ!Box 7430](http://geni.us/BlAP)
|
||||||
- [FRITZ!Box 7490](http://geni.us/fTyoY)
|
- [FRITZ!Box 7490](http://geni.us/fTyoY)
|
||||||
|
- [FRITZ!Box 7530](https://geni.us/h8oqYd)
|
||||||
|
- [FRITZ!Box 7530 AX](https://geni.us/a4dS5)
|
||||||
- [FRITZ!Box 7560](http://geni.us/6gPZNI)
|
- [FRITZ!Box 7560](http://geni.us/6gPZNI)
|
||||||
- [FRITZ!Box 7580](http://geni.us/yUYyQTE)
|
- [FRITZ!Box 7580](http://geni.us/yUYyQTE)
|
||||||
- [FRITZ!Box 7590](http://geni.us/OO2c7S)
|
- [FRITZ!Box 7590](http://geni.us/OO2c7S)
|
||||||
@ -41,32 +43,32 @@ If you are using the scripts on a different Fritz!Box model please let me know b
|
|||||||
|
|
||||||
## fritzbox\_cpu\_usage
|
## fritzbox\_cpu\_usage
|
||||||
|
|
||||||
fritzbox\_cpu\_usage shows you the cpu usage (requires password)
|
fritzbox\_cpu\_usage shows you the cpu usage (requires username & password)
|
||||||
![http://i.imgur.com/A9uGvWP.png](http://i.imgur.com/A9uGvWP.png)
|
![http://i.imgur.com/A9uGvWP.png](http://i.imgur.com/A9uGvWP.png)
|
||||||
|
|
||||||
## fritzbox\_cpu\_temperature
|
## fritzbox\_cpu\_temperature
|
||||||
|
|
||||||
fritzbox\_cpu\_temperature shows you the cpu temperature (requires password)
|
fritzbox\_cpu\_temperature shows you the cpu temperature (requires username & password)
|
||||||
![http://i.imgur.com/duHYhw6.png](http://i.imgur.com/duHYhw6.png)
|
![http://i.imgur.com/duHYhw6.png](http://i.imgur.com/duHYhw6.png)
|
||||||
|
|
||||||
## fritzbox\_memory\_usage
|
## fritzbox\_memory\_usage
|
||||||
|
|
||||||
fritzbox\_memory\_usage shows you the memory usage (requires password)
|
fritzbox\_memory\_usage shows you the memory usage (requires username & password)
|
||||||
![http://i.imgur.com/WhxrINK.png](http://i.imgur.com/WhxrINK.png)
|
![http://i.imgur.com/WhxrINK.png](http://i.imgur.com/WhxrINK.png)
|
||||||
|
|
||||||
## fritzbox\_power\_consumption
|
## fritzbox\_power\_consumption
|
||||||
|
|
||||||
fritzbox\_power\_consumption shows you the power consumption (requires password)
|
fritzbox\_power\_consumption shows you the power consumption (requires username & password)
|
||||||
![http://i.imgur.com/a7uQzn6.png](http://i.imgur.com/a7uQzn6.png)
|
![http://i.imgur.com/a7uQzn6.png](http://i.imgur.com/a7uQzn6.png)
|
||||||
|
|
||||||
## fritzbox\_uptime
|
## fritzbox\_uptime
|
||||||
|
|
||||||
fritzbox\_uptime shows you the uptime in days (requires password) (language dependant, see below).
|
fritzbox\_uptime shows you the uptime in days (requires username & password) (language dependant, see below).
|
||||||
![http://i.imgur.com/Jr8OibH.png](http://i.imgur.com/Jr8OibH.png)
|
![http://i.imgur.com/Jr8OibH.png](http://i.imgur.com/Jr8OibH.png)
|
||||||
|
|
||||||
## fritzbox\_wifi\_devices
|
## fritzbox\_wifi\_devices
|
||||||
|
|
||||||
fritzbox\_wifi\_devices shows you the number of connected wifi clients (requires password) (language dependant, see below).
|
fritzbox\_wifi\_devices shows you the number of connected wifi clients (requires username & password) (language dependant, see below).
|
||||||
![http://i.imgur.com/lqvK1b2.png](http://i.imgur.com/lqvK1b2.png)
|
![http://i.imgur.com/lqvK1b2.png](http://i.imgur.com/lqvK1b2.png)
|
||||||
|
|
||||||
## Installation & Configuration
|
## Installation & Configuration
|
||||||
@ -85,6 +87,7 @@ If you are using the scripts on a different Fritz!Box model please let me know b
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip <ip_address_to_your_fritzbox>
|
env.fritzbox_ip <ip_address_to_your_fritzbox>
|
||||||
|
env.fritzbox_username <fritzbox_username>
|
||||||
env.fritzbox_password <fritzbox_password>
|
env.fritzbox_password <fritzbox_password>
|
||||||
env.traffic_remove_max true # if you do not want the possible max values
|
env.traffic_remove_max true # if you do not want the possible max values
|
||||||
host_name fritzbox
|
host_name fritzbox
|
||||||
|
@ -10,6 +10,12 @@
|
|||||||
This plugin requires the fritzconnection plugin. To install it using pip:
|
This plugin requires the fritzconnection plugin. To install it using pip:
|
||||||
pip install fritzconnection
|
pip install fritzconnection
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
|
|
||||||
|
[fritzbox_*]
|
||||||
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
#%# family=auto contrib
|
#%# family=auto contrib
|
||||||
#%# capabilities=autoconf
|
#%# capabilities=autoconf
|
||||||
"""
|
"""
|
||||||
@ -17,37 +23,41 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from fritzconnection import FritzConnection
|
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||||
|
|
||||||
|
server = os.environ["fritzbox_ip"]
|
||||||
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
|
|
||||||
def print_values():
|
def print_values():
|
||||||
try:
|
try:
|
||||||
conn = FritzConnection(address=os.environ['fritzbox_ip'])
|
fs = FritzStatus(address=server, user=username, password=password)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.exit("Couldn't get connection uptime")
|
sys.exit("Couldn't get connection uptime")
|
||||||
|
|
||||||
uptime = conn.call_action('WANIPConnection', 'GetStatusInfo')['NewUptime']
|
uptime = fs.uptime
|
||||||
print('uptime.value %.2f' % (int(uptime) / 86400.0))
|
print("uptime.value %.2f" % (int(uptime) / 86400.0))
|
||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
print("graph_title AVM Fritz!Box Connection Uptime")
|
print("graph_title AVM Fritz!Box Connection Uptime")
|
||||||
print("graph_args --base 1000 -l 0")
|
print("graph_args --base 1000 -l 0")
|
||||||
print('graph_vlabel uptime in days')
|
print("graph_vlabel uptime in days")
|
||||||
print("graph_scale no'")
|
print("graph_scale no'")
|
||||||
print("graph_category network")
|
print("graph_category network")
|
||||||
print("uptime.label uptime")
|
print("uptime.label uptime")
|
||||||
print("uptime.draw AREA")
|
print("uptime.draw AREA")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print("yes") # Some docs say it'll be called with fetch, some say no arg at all
|
print("yes") # Some docs say it'll be called with fetch, some say no arg at all
|
||||||
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == "fetch"):
|
||||||
try:
|
try:
|
||||||
print_values()
|
print_values()
|
||||||
except:
|
except:
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip [ip address of the fritzbox]
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
env.fritzbox_password [fritzbox password]
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
@ -20,19 +21,20 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
PAGE = 'ecoStat'
|
PAGE = "ecoStat"
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_temperature():
|
def get_cpu_temperature():
|
||||||
"""get the current cpu temperature"""
|
"""get the current cpu temperature"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = os.environ["fritzbox_ip"]
|
||||||
password = os.environ['fritzbox_password']
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, username, password)
|
||||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||||
data = json.loads(xhr_data)
|
data = json.loads(xhr_data)
|
||||||
print('temp.value %d' % (int(data['data']['cputemp']['series'][0][-1])))
|
print("temp.value %d" % (int(data["data"]["cputemp"]["series"][0][-1])))
|
||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
@ -46,15 +48,15 @@ def print_config():
|
|||||||
print("temp.graph LINE1")
|
print("temp.graph LINE1")
|
||||||
print("temp.min 0")
|
print("temp.min 0")
|
||||||
print("temp.info Fritzbox CPU temperature")
|
print("temp.info Fritzbox CPU temperature")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print('yes')
|
print("yes")
|
||||||
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
|
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# Some docs say it'll be called with fetch, some say no arg at all
|
||||||
get_cpu_temperature()
|
get_cpu_temperature()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip [ip address of the fritzbox]
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
env.fritzbox_password [fritzbox password]
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
@ -20,19 +21,20 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
PAGE = 'ecoStat'
|
PAGE = "ecoStat"
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_usage():
|
def get_cpu_usage():
|
||||||
"""get the current cpu usage"""
|
"""get the current cpu usage"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = os.environ["fritzbox_ip"]
|
||||||
password = os.environ['fritzbox_password']
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, username, password)
|
||||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||||
data = json.loads(xhr_data)
|
data = json.loads(xhr_data)
|
||||||
print('cpu.value %d' % (int(data['data']['cpuutil']['series'][0][-1])))
|
print("cpu.value %d" % (int(data["data"]["cpuutil"]["series"][0][-1])))
|
||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
@ -46,16 +48,16 @@ def print_config():
|
|||||||
print("cpu.graph AREA")
|
print("cpu.graph AREA")
|
||||||
print("cpu.min 0")
|
print("cpu.min 0")
|
||||||
print("cpu.info Fritzbox CPU usage")
|
print("cpu.info Fritzbox CPU usage")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print('yes')
|
print("yes")
|
||||||
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
|
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# Some docs say it'll be called with fetch, some say no arg at all
|
||||||
try:
|
try:
|
||||||
get_cpu_usage()
|
get_cpu_usage()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip [ip address of the fritzbox]
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
env.fritzbox_password [fritzbox password]
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
@ -18,69 +19,103 @@
|
|||||||
The initial script was inspired by
|
The initial script was inspired by
|
||||||
https://www.linux-tips-and-tricks.de/en/programming/389-read-data-from-a-fritzbox-7390-with-python-and-bash
|
https://www.linux-tips-and-tricks.de/en/programming/389-read-data-from-a-fritzbox-7390-with-python-and-bash
|
||||||
framp at linux-tips-and-tricks dot de
|
framp at linux-tips-and-tricks dot de
|
||||||
|
|
||||||
|
New authentication supporting username and password, as well as PBKDF2 support, has been inspired by
|
||||||
|
https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM%20Technical%20Note%20-%20Session%20ID_englisch.pdf
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0"
|
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0"
|
||||||
|
|
||||||
|
LOGIN_SID_ROUTE = "/login_sid.lua?version=2"
|
||||||
|
|
||||||
def get_session_id(server, password, 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
|
class LoginState:
|
||||||
:param password: the password to log into the Fritzbox webinterface
|
def __init__(self, challenge: str, blocktime: int):
|
||||||
:param port: the port the Fritzbox webserver runs on
|
self.challenge = challenge
|
||||||
:return: the session id
|
self.blocktime = blocktime
|
||||||
"""
|
self.is_pbkdf2 = challenge.startswith("2$")
|
||||||
|
|
||||||
headers = {"Accept": "application/xml",
|
|
||||||
"Content-Type": "text/plain",
|
|
||||||
"User-Agent": USER_AGENT}
|
|
||||||
|
|
||||||
url = 'http://{}:{}/login_sid.lua'.format(server, port)
|
def get_session_id(server: str, username: str, password: str, port: int = 80) -> str:
|
||||||
|
""" Get a sid by solving the PBKDF2 (or MD5) challenge-response process. """
|
||||||
|
box_url = "http://{}:{}".format(server, port)
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, headers=headers)
|
state = get_login_state(box_url)
|
||||||
r.raise_for_status()
|
except Exception as ex:
|
||||||
except requests.exceptions.HTTPError as err:
|
raise Exception("failed to get challenge") from ex
|
||||||
print(err)
|
if state.is_pbkdf2:
|
||||||
sys.exit(1)
|
# print("PBKDF2 supported")
|
||||||
|
challenge_response = calculate_pbkdf2_response(state.challenge, password)
|
||||||
root = etree.fromstring(r.content)
|
|
||||||
session_id = root.xpath('//SessionInfo/SID/text()')[0]
|
|
||||||
if session_id == "0000000000000000":
|
|
||||||
challenge = root.xpath('//SessionInfo/Challenge/text()')[0]
|
|
||||||
challenge_bf = ('{}-{}'.format(challenge, password)).encode('utf-16le')
|
|
||||||
m = hashlib.md5()
|
|
||||||
m.update(challenge_bf)
|
|
||||||
response_bf = '{}-{}'.format(challenge, m.hexdigest().lower())
|
|
||||||
else:
|
else:
|
||||||
return session_id
|
# print("Falling back to MD5")
|
||||||
|
challenge_response = calculate_md5_response(state.challenge, password)
|
||||||
headers = {"Accept": "text/html,application/xhtml+xml,application/xml",
|
if state.blocktime > 0:
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
# print(f"Waiting for {state.blocktime} seconds...")
|
||||||
"User-Agent": USER_AGENT}
|
time.sleep(state.blocktime)
|
||||||
|
|
||||||
url = 'http://{}:{}/login_sid.lua?&response={}'.format(server, port, response_bf)
|
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, headers=headers)
|
sid = send_response(box_url, username, challenge_response)
|
||||||
r.raise_for_status()
|
except Exception as ex:
|
||||||
except requests.exceptions.HTTPError as err:
|
raise Exception("failed to login") from ex
|
||||||
print(err)
|
if sid == "0000000000000000":
|
||||||
sys.exit(1)
|
raise Exception("wrong username or password")
|
||||||
|
return sid
|
||||||
|
|
||||||
root = etree.fromstring(r.content)
|
|
||||||
session_id = root.xpath('//SessionInfo/SID/text()')[0]
|
def get_login_state(box_url: str) -> LoginState:
|
||||||
if session_id == "0000000000000000":
|
""" Get login state from FRITZ!Box using login_sid.lua?version=2 """
|
||||||
print("ERROR - No SID received because of invalid password")
|
url = box_url + LOGIN_SID_ROUTE
|
||||||
sys.exit(0)
|
r = requests.get(url)
|
||||||
return session_id
|
xml = etree.fromstring(r.content)
|
||||||
|
challenge = xml.find("Challenge").text
|
||||||
|
blocktime = int(xml.find("BlockTime").text)
|
||||||
|
return LoginState(challenge, blocktime)
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_pbkdf2_response(challenge: str, password: str) -> str:
|
||||||
|
""" Calculate the response for a given challenge via PBKDF2 """
|
||||||
|
challenge_parts = challenge.split("$")
|
||||||
|
# Extract all necessary values encoded into the challenge
|
||||||
|
iter1 = int(challenge_parts[1])
|
||||||
|
salt1 = bytes.fromhex(challenge_parts[2])
|
||||||
|
iter2 = int(challenge_parts[3])
|
||||||
|
salt2 = bytes.fromhex(challenge_parts[4])
|
||||||
|
# Hash twice, once with static salt...
|
||||||
|
# Once with dynamic salt.
|
||||||
|
hash1 = hashlib.pbkdf2_hmac("sha256", password.encode(), salt1, iter1)
|
||||||
|
hash2 = hashlib.pbkdf2_hmac("sha256", hash1, salt2, iter2)
|
||||||
|
return f"{challenge_parts[4]}${hash2.hex()}"
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_md5_response(challenge: str, password: str) -> str:
|
||||||
|
""" Calculate the response for a challenge using legacy MD5 """
|
||||||
|
response = challenge + "-" + password
|
||||||
|
# the legacy response needs utf_16_le encoding
|
||||||
|
response = response.encode("utf_16_le")
|
||||||
|
md5_sum = hashlib.md5()
|
||||||
|
md5_sum.update(response)
|
||||||
|
response = challenge + "-" + md5_sum.hexdigest()
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def send_response(box_url: str, username: str, challenge_response: str) -> str:
|
||||||
|
""" Send the response and return the parsed sid. raises an Exception on error """
|
||||||
|
# Build response params
|
||||||
|
post_data = {"username": username, "response": challenge_response}
|
||||||
|
# post_data = urllib.parse.urlencode(post_data_dict).encode()
|
||||||
|
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
||||||
|
url = box_url + LOGIN_SID_ROUTE
|
||||||
|
r = requests.post(url, headers=headers, data=post_data)
|
||||||
|
# Parse SID from resulting XML.
|
||||||
|
xml = etree.fromstring(r.content)
|
||||||
|
return xml.find("SID").text
|
||||||
|
|
||||||
|
|
||||||
def get_page_content(server, session_id, page, port=80):
|
def get_page_content(server, session_id, page, port=80):
|
||||||
@ -93,11 +128,9 @@ def get_page_content(server, session_id, page, port=80):
|
|||||||
:return: the content of the page
|
:return: the content of the page
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers = {"Accept": "application/xml",
|
headers = {"Accept": "application/xml", "Content-Type": "text/plain", "User-Agent": USER_AGENT}
|
||||||
"Content-Type": "text/plain",
|
|
||||||
"User-Agent": USER_AGENT}
|
|
||||||
|
|
||||||
url = 'http://{}:{}/{}?sid={}'.format(server, port, page, session_id)
|
url = "http://{}:{}/{}?sid={}".format(server, port, page, session_id)
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, headers=headers)
|
r = requests.get(url, headers=headers)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
@ -117,18 +150,14 @@ def get_xhr_content(server, session_id, page, port=80):
|
|||||||
:return: the content of the page
|
:return: the content of the page
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers = {"Accept": "application/xml",
|
headers = {
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Accept": "application/xml",
|
||||||
"User-Agent": USER_AGENT}
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"User-Agent": USER_AGENT,
|
||||||
|
}
|
||||||
|
|
||||||
url = 'http://{}:{}/data.lua'.format(server, port)
|
url = "http://{}:{}/data.lua".format(server, port)
|
||||||
data = {"xhr": 1,
|
data = {"xhr": 1, "sid": session_id, "lang": "en", "page": page, "xhrId": "all", "no_sidrenew": ""}
|
||||||
"sid": session_id,
|
|
||||||
"lang": "en",
|
|
||||||
"page": page,
|
|
||||||
"xhrId": "all",
|
|
||||||
"no_sidrenew": ""
|
|
||||||
}
|
|
||||||
try:
|
try:
|
||||||
r = requests.post(url, data=data, headers=headers)
|
r = requests.post(url, data=data, headers=headers)
|
||||||
except requests.exceptions.HTTPError as err:
|
except requests.exceptions.HTTPError as err:
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip [ip address of the fritzbox]
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
env.fritzbox_password [fritzbox password]
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
@ -20,21 +21,22 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
PAGE = 'ecoStat'
|
PAGE = "ecoStat"
|
||||||
USAGE = ['strict', 'cache', 'free']
|
USAGE = ["strict", "cache", "free"]
|
||||||
|
|
||||||
|
|
||||||
def get_memory_usage():
|
def get_memory_usage():
|
||||||
"""get the current memory usage"""
|
"""get the current memory usage"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = os.environ["fritzbox_ip"]
|
||||||
password = os.environ['fritzbox_password']
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, username, password)
|
||||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||||
data = json.loads(xhr_data)
|
data = json.loads(xhr_data)
|
||||||
for i, usage in enumerate(USAGE):
|
for i, usage in enumerate(USAGE):
|
||||||
print('%s.value %s' % (usage, data['data']['ramusage']['series'][i][-1]))
|
print("%s.value %s" % (usage, data["data"]["ramusage"]["series"][i][-1]))
|
||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
@ -54,16 +56,16 @@ def print_config():
|
|||||||
print("free.label free")
|
print("free.label free")
|
||||||
print("free.type GAUGE")
|
print("free.type GAUGE")
|
||||||
print("free.draw STACK")
|
print("free.draw STACK")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print('yes')
|
print("yes")
|
||||||
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
|
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# Some docs say it'll be called with fetch, some say no arg at all
|
||||||
try:
|
try:
|
||||||
get_memory_usage()
|
get_memory_usage()
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip [ip address of the fritzbox]
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
env.fritzbox_password [fritzbox password]
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
@ -22,22 +23,23 @@ import sys
|
|||||||
|
|
||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
PAGE = 'energy'
|
PAGE = "energy"
|
||||||
DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
|
DEVICES = ["system", "cpu", "wifi", "dsl", "ab", "usb"]
|
||||||
|
|
||||||
|
|
||||||
def get_power_consumption():
|
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"]
|
||||||
password = os.environ['fritzbox_password']
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, username, password)
|
||||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||||
data = json.loads(xhr_data)
|
data = json.loads(xhr_data)
|
||||||
devices = data['data']['drain']
|
devices = data["data"]["drain"]
|
||||||
for i, device in enumerate(DEVICES):
|
for i, device in enumerate(DEVICES):
|
||||||
print('%s.value %s' % (device, devices[i]['actPerc']))
|
print("%s.value %s" % (device, devices[i]["actPerc"]))
|
||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
@ -81,16 +83,16 @@ def print_config():
|
|||||||
print("usb.min 0")
|
print("usb.min 0")
|
||||||
print("usb.max 100")
|
print("usb.max 100")
|
||||||
print("usb.info Fritzbox usb devices power consumption")
|
print("usb.info Fritzbox usb devices power consumption")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print('yes')
|
print("yes")
|
||||||
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
|
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# Some docs say it'll be called with fetch, some say no arg at all
|
||||||
try:
|
try:
|
||||||
get_power_consumption()
|
get_power_consumption()
|
||||||
|
@ -10,6 +10,12 @@
|
|||||||
This plugin requires the fritzconnection plugin. To install it using pip:
|
This plugin requires the fritzconnection plugin. To install it using pip:
|
||||||
pip install fritzconnection
|
pip install fritzconnection
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
|
|
||||||
|
[fritzbox_*]
|
||||||
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
#%# family=auto contrib
|
#%# family=auto contrib
|
||||||
#%# capabilities=autoconf
|
#%# capabilities=autoconf
|
||||||
"""
|
"""
|
||||||
@ -17,29 +23,33 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from fritzconnection import FritzConnection
|
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||||
|
|
||||||
|
server = os.environ["fritzbox_ip"]
|
||||||
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
|
|
||||||
def print_values():
|
def print_values():
|
||||||
try:
|
try:
|
||||||
conn = FritzConnection(address=os.environ['fritzbox_ip'])
|
fs = FritzStatus(address=server, user=username, password=password)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.exit("Couldn't get WAN traffic")
|
sys.exit("Couldn't get WAN traffic")
|
||||||
|
|
||||||
down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesReceived')['NewTotalBytesReceived']
|
traffic = fs.transmission_rate
|
||||||
print('down.value %d' % down_traffic)
|
down_traffic = traffic[1]
|
||||||
|
print("down.value %d" % down_traffic)
|
||||||
|
|
||||||
up_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesSent')['NewTotalBytesSent']
|
up_traffic = traffic[0]
|
||||||
print('up.value %d' % up_traffic)
|
print("up.value %d" % up_traffic)
|
||||||
|
|
||||||
if not os.environ.get('traffic_remove_max'):
|
if not os.environ.get("traffic_remove_max"):
|
||||||
max_down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')[
|
max_traffic = fs.max_bit_rate
|
||||||
'NewLayer1DownstreamMaxBitRate']
|
max_down_traffic = max_traffic[1]
|
||||||
print('maxdown.value %d' % max_down_traffic)
|
print("maxdown.value %d" % max_down_traffic)
|
||||||
|
|
||||||
max_up_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')[
|
max_up_traffic = max_traffic[0]
|
||||||
'NewLayer1UpstreamMaxBitRate']
|
print("maxup.value %d" % max_up_traffic)
|
||||||
print('maxup.value %d' % max_up_traffic)
|
|
||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
@ -62,7 +72,7 @@ def print_config():
|
|||||||
print("up.max 1000000000")
|
print("up.max 1000000000")
|
||||||
print("up.negative down")
|
print("up.negative down")
|
||||||
print("up.info Traffic of the WAN interface.")
|
print("up.info Traffic of the WAN interface.")
|
||||||
if not os.environ.get('traffic_remove_max'):
|
if not os.environ.get("traffic_remove_max"):
|
||||||
print("maxdown.label received")
|
print("maxdown.label received")
|
||||||
print("maxdown.type GAUGE")
|
print("maxdown.type GAUGE")
|
||||||
print("maxdown.graph no")
|
print("maxdown.graph no")
|
||||||
@ -71,16 +81,16 @@ def print_config():
|
|||||||
print("maxup.negative maxdown")
|
print("maxup.negative maxdown")
|
||||||
print("maxup.draw LINE1")
|
print("maxup.draw LINE1")
|
||||||
print("maxup.info Maximum speed of the WAN interface.")
|
print("maxup.info Maximum speed of the WAN interface.")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print("yes") # Some docs say it'll be called with fetch, some say no arg at all
|
print("yes") # Some docs say it'll be called with fetch, some say no arg at all
|
||||||
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == "fetch"):
|
||||||
try:
|
try:
|
||||||
print_values()
|
print_values()
|
||||||
except:
|
except:
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip [ip address of the fritzbox]
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
env.fritzbox_password [fritzbox password]
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
@ -22,29 +23,29 @@ import sys
|
|||||||
|
|
||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
locale = os.environ.get('locale', 'de')
|
locale = os.environ.get("locale", "de")
|
||||||
patternLoc = {"de": r"(\d+)\s(Tag|Stunden|Minuten)",
|
patternLoc = {"de": r"(\d+)\s(Tag|Stunden|Minuten)", "en": r"(\d+)\s(days|hours|minutes)"}
|
||||||
"en": r"(\d+)\s(days|hours|minutes)"}
|
|
||||||
dayLoc = {"de": "Tag", "en": "days"}
|
dayLoc = {"de": "Tag", "en": "days"}
|
||||||
hourLoc = {"de": "Stunden", "en": "hours"}
|
hourLoc = {"de": "Stunden", "en": "hours"}
|
||||||
minutesLoc = {"de": "Minuten", "en": "minutes"}
|
minutesLoc = {"de": "Minuten", "en": "minutes"}
|
||||||
|
|
||||||
PAGE = 'energy'
|
PAGE = "energy"
|
||||||
pattern = re.compile(patternLoc[locale])
|
pattern = re.compile(patternLoc[locale])
|
||||||
|
|
||||||
|
|
||||||
def get_uptime():
|
def get_uptime():
|
||||||
"""get the current uptime"""
|
"""get the current uptime"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = os.environ["fritzbox_ip"]
|
||||||
password = os.environ['fritzbox_password']
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, username, password)
|
||||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||||
data = json.loads(xhr_data)
|
data = json.loads(xhr_data)
|
||||||
for d in data['data']['drain']:
|
for d in data["data"]["drain"]:
|
||||||
if 'aktiv' in d['statuses']:
|
if "aktiv" in d["statuses"]:
|
||||||
matches = re.finditer(pattern, d['statuses'])
|
matches = re.finditer(pattern, d["statuses"])
|
||||||
if matches:
|
if matches:
|
||||||
hours = 0.0
|
hours = 0.0
|
||||||
for m in matches:
|
for m in matches:
|
||||||
@ -61,21 +62,21 @@ def get_uptime():
|
|||||||
def print_config():
|
def print_config():
|
||||||
print("graph_title AVM Fritz!Box Uptime")
|
print("graph_title AVM Fritz!Box Uptime")
|
||||||
print("graph_args --base 1000 -l 0")
|
print("graph_args --base 1000 -l 0")
|
||||||
print('graph_vlabel uptime in days')
|
print("graph_vlabel uptime in days")
|
||||||
print("graph_scale no'")
|
print("graph_scale no'")
|
||||||
print("graph_category system")
|
print("graph_category system")
|
||||||
print("uptime.label uptime")
|
print("uptime.label uptime")
|
||||||
print("uptime.draw AREA")
|
print("uptime.draw AREA")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print('yes')
|
print("yes")
|
||||||
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
|
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# Some docs say it'll be called with fetch, some say no arg at all
|
||||||
try:
|
try:
|
||||||
get_uptime()
|
get_uptime()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip [ip address of the fritzbox]
|
env.fritzbox_ip [ip address of the fritzbox]
|
||||||
|
env.fritzbox_username [fritzbox username]
|
||||||
env.fritzbox_password [fritzbox password]
|
env.fritzbox_password [fritzbox password]
|
||||||
|
|
||||||
This plugin supports the following munin configuration parameters:
|
This plugin supports the following munin configuration parameters:
|
||||||
@ -22,49 +23,49 @@ import sys
|
|||||||
|
|
||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
locale = os.environ.get('locale', 'de')
|
locale = os.environ.get("locale", "de")
|
||||||
patternLoc = {"de": r"(\d+) WLAN",
|
patternLoc = {"de": r"(\d+) WLAN", "en": r"(\d+) wireless LAN"}
|
||||||
"en": r"(\d+) wireless LAN"}
|
|
||||||
|
|
||||||
PAGE = 'energy'
|
PAGE = "energy"
|
||||||
pattern = re.compile(patternLoc[locale])
|
pattern = re.compile(patternLoc[locale])
|
||||||
|
|
||||||
|
|
||||||
def get_connected_wifi_devices():
|
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"]
|
||||||
password = os.environ['fritzbox_password']
|
username = os.environ["fritzbox_username"]
|
||||||
|
password = os.environ["fritzbox_password"]
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, username, password)
|
||||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||||
data = json.loads(xhr_data)
|
data = json.loads(xhr_data)
|
||||||
m = re.search(pattern, data['data']['drain'][2]['statuses'][-1])
|
m = re.search(pattern, data["data"]["drain"][2]["statuses"][-1])
|
||||||
if m:
|
if m:
|
||||||
connected_devices = int(m.group(1))
|
connected_devices = int(m.group(1))
|
||||||
print('wifi.value %d' % connected_devices)
|
print("wifi.value %d" % connected_devices)
|
||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
print('graph_title AVM Fritz!Box Connected Wifi Devices')
|
print("graph_title AVM Fritz!Box Connected Wifi Devices")
|
||||||
print('graph_vlabel Number of devices')
|
print("graph_vlabel Number of devices")
|
||||||
print('graph_args --base 1000')
|
print("graph_args --base 1000")
|
||||||
print('graph_category network')
|
print("graph_category network")
|
||||||
print('graph_order wifi')
|
print("graph_order wifi")
|
||||||
print('wifi.label Wifi Connections on 2.4 & 5 Ghz')
|
print("wifi.label Wifi Connections on 2.4 & 5 Ghz")
|
||||||
print('wifi.type GAUGE')
|
print("wifi.type GAUGE")
|
||||||
print('wifi.graph LINE1')
|
print("wifi.graph LINE1")
|
||||||
print('wifi.info Wifi Connections on 2.4 & 5 Ghz')
|
print("wifi.info Wifi Connections on 2.4 & 5 Ghz")
|
||||||
if os.environ.get('host_name'):
|
if os.environ.get("host_name"):
|
||||||
print("host_name " + os.environ['host_name'])
|
print("host_name " + os.environ["host_name"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
if len(sys.argv) == 2 and sys.argv[1] == "config":
|
||||||
print_config()
|
print_config()
|
||||||
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf":
|
||||||
print('yes')
|
print("yes")
|
||||||
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
|
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == "fetch":
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# Some docs say it'll be called with fetch, some say no arg at all
|
||||||
try:
|
try:
|
||||||
get_connected_wifi_devices()
|
get_connected_wifi_devices()
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
fritzconnection
|
fritzconnection
|
||||||
lxml
|
lxml
|
||||||
requests
|
requests
|
||||||
|
Loading…
Reference in New Issue
Block a user