mirror of
https://github.com/Tafkas/fritzbox-munin.git
synced 2023-10-10 11:36:55 +00:00
fix #9: support authentication with username
This commit is contained in:
parent
ea8badd3a4
commit
ca681ec326
@ -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:
|
||||||
@ -29,9 +30,10 @@ 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']
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
sid = fh.get_sid(server, password)
|
sid = fh.get_sid(server, username, password)
|
||||||
data = fh.get_page(server, sid, PAGE)
|
data = fh.get_page(server, sid, PAGE)
|
||||||
|
|
||||||
m = re.search(pattern, data)
|
m = re.search(pattern, data)
|
||||||
|
@ -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:
|
||||||
@ -29,9 +30,10 @@ 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']
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
sid = fh.get_sid(server, password)
|
sid = fh.get_sid(server, username, password)
|
||||||
data = fh.get_page(server, sid, PAGE)
|
data = fh.get_page(server, sid, PAGE)
|
||||||
|
|
||||||
m = re.search(pattern, data)
|
m = re.search(pattern, data)
|
||||||
|
@ -25,7 +25,7 @@ from xml.dom import minidom
|
|||||||
USER_AGENT = "Mozilla/5.0 (U; Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
|
USER_AGENT = "Mozilla/5.0 (U; Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
|
||||||
|
|
||||||
|
|
||||||
def get_sid(server, password, port=80):
|
def get_sid(server, username, password, port=80):
|
||||||
"""Obtains the sid after login into the fritzbox"""
|
"""Obtains the sid after login into the fritzbox"""
|
||||||
conn = httplib.HTTPConnection(server + ':' + str(port))
|
conn = httplib.HTTPConnection(server + ':' + str(port))
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ def get_sid(server, 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?&response=" + response_bf
|
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()
|
||||||
@ -69,6 +69,7 @@ def get_sid(server, password, port=80):
|
|||||||
sid = re.search("<SID>(.*?)</SID>", data).group(1)
|
sid = re.search("<SID>(.*?)</SID>", data).group(1)
|
||||||
if sid == "0000000000000000":
|
if sid == "0000000000000000":
|
||||||
print "ERROR - No SID received because of invalid password"
|
print "ERROR - No SID received because of invalid password"
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
return sid
|
return sid
|
||||||
|
|
||||||
|
@ -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:
|
||||||
@ -30,9 +31,10 @@ 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']
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
sid = fh.get_sid(server, password)
|
sid = fh.get_sid(server, username, password)
|
||||||
data = fh.get_page(server, sid, PAGE)
|
data = fh.get_page(server, sid, PAGE)
|
||||||
matches = re.finditer(pattern, data)
|
matches = re.finditer(pattern, data)
|
||||||
if matches:
|
if matches:
|
||||||
|
@ -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:
|
||||||
@ -30,9 +31,10 @@ 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']
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
sid = fh.get_sid(server, password)
|
sid = fh.get_sid(server, username, password)
|
||||||
data = fh.get_page(server, sid, PAGE)
|
data = fh.get_page(server, sid, PAGE)
|
||||||
matches = re.finditer(pattern, data)
|
matches = re.finditer(pattern, data)
|
||||||
if matches:
|
if matches:
|
||||||
|
@ -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:
|
||||||
@ -29,9 +30,10 @@ 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']
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
sid = fh.get_sid(server, password)
|
sid = fh.get_sid(server, username, username, password)
|
||||||
data = fh.get_page(server, sid, PAGE)
|
data = fh.get_page(server, sid, PAGE)
|
||||||
matches = re.finditer(pattern, data)
|
matches = re.finditer(pattern, data)
|
||||||
if matches:
|
if matches:
|
||||||
|
@ -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:
|
||||||
@ -29,9 +30,10 @@ 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']
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
sid = fh.get_sid(server, password)
|
sid = fh.get_sid(server, username, password)
|
||||||
data = fh.get_page(server, sid, PAGE)
|
data = fh.get_page(server, sid, PAGE)
|
||||||
m = re.search(pattern, data)
|
m = re.search(pattern, data)
|
||||||
if m:
|
if m:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user