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

11 Commits

Author SHA1 Message Date
Christian Stade-Schuldt
cd269783bd update Readme 2018-09-11 23:15:34 +02:00
Christian Stade-Schuldt
3364b29ec1 remove invalid parantheses 2018-07-04 01:00:36 +02:00
Christian Stade-Schuldt
ee66451dcc update README 2018-03-16 19:34:18 +01:00
Christian Stade-Schuldt
34ee94ce1d update README and Contributors 2017-11-04 17:04:42 +01:00
Christian Stade-Schuldt
666e3d0a0a changes towards python 3 compatibility 2017-11-04 17:04:26 +01:00
Christian Stade-Schuldt
bfdeb190f3 use lxml for parsing and better error handling 2017-11-04 17:04:00 +01:00
Christian Stade-Schuldt
a2fb8f7dc7 update README 2017-10-13 20:45:19 +02:00
Christian Stade-Schuldt
5f64d24d9c Merge pull request #22 from cweiske/patch-1
Talk about the UPnP status setting
2017-10-13 20:35:36 +02:00
Christian Weiske
9264e49e27 Talk about the UPnP status setting
If you don't enable that, you'll get an exception: Unknown Service: WANIPConnection:1
2017-10-13 20:29:05 +02:00
Christian Stade-Schuldt
c5cdb516d7 format readme 2017-09-06 23:42:55 +02:00
Christian Stade-Schuldt
42c1d2461d add CONTRIBUTORS.md 2017-09-06 22:58:39 +02:00
11 changed files with 251 additions and 227 deletions

4
CONTRIBUTORS.md Normal file
View File

@@ -0,0 +1,4 @@
## fritzbox-munin contributors
- Bob van de Vijver ([bobvandevijver](https://github.com/bobvandevijver))
- Framps ([framps](https://github.com/framps))

View File

@@ -1,6 +1,6 @@
# fritzbox-munin
A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a [FRITZ!Box 7362 SL](http://geni.us/fTyoY)(Amazon link) running FRITZ!OS 06.83.
A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a [FRITZ!Box 7590](http://geni.us/OO2c7S)(Amazon link) running FRITZ!OS 7.00.
If you are using the scripts on a different Fritz!Box model please let me know by
@@ -9,12 +9,14 @@ If you are using the scripts on a different Fritz!Box model please let me know b
So far the following models (running FRITZ!OS 06.83) have been confirmed working:
- [FRITZ!Box 3370](http://geni.us/zh3U)
- [FRITZ!Box 5490](http://geni.us/ACtUyFt)
- [FRITZ!Box 7362 SL](http://geni.us/fTyoY)
- [FRITZ!Box 7390](http://geni.us/BlAP)
- [FRITZ!Box 7430](http://geni.us/BlAP)
- [FRITZ!Box 7490](http://geni.us/fTyoY)
- [FRITZ!Box 7580](http://geni.us/yUYyQTE)
- [FRITZ!Box 7590](http://geni.us/OO2c7S)
If you are still running Fritz!OS 6.30 check out the [releases section](https://github.com/Tafkas/fritzbox-munin/releases/tag/6.30.1).
@@ -69,23 +71,26 @@ If you are using the scripts on a different Fritz!Box model please let me know b
## Installation & Configuration
0. Pre-requesites for the fritzbox\_traffic and fritzbox\_uptime plugins is the [fritzconnection](https://pypi.python.org/pypi/fritzconnection) package. To install it
0. Pre-requesites for the fritzbox\_traffic and fritzbox\_uptime plugins are the [fritzconnection](https://pypi.python.org/pypi/fritzconnection) and [requests](https://pypi.python.org/pypi/requests) package. To install it
pip install fritzconnection
pip install requests
1. Copy all the scripts to `/usr/share/munin/plugins`
1. Make sure the FritzBox has UPnP status information enabled. (German interface: Heimnetz > Heimnetzübersicht > Netzwerkeinstellungen > Statusinformationen über UPnP übertragen)
2. Copy all the scripts to `/usr/share/munin/plugins`
2. Create entry in `/etc/munin/plugin-conf.d/munin-node`:
3. Create entry in `/etc/munin/plugin-conf.d/munin-node`:
[fritzbox_*]
env.fritzbox_ip <ip_address_to_your_fritzbox>
env.fritzbox_password <fritzbox_password>
3. Create symbolic links to `/etc/munin/plugins`.
4. Create symbolic links to `/etc/munin/plugins`.
4. Restart the munin-node daemon: `/etc/init.d/munin-node restart`.
5. Restart the munin-node daemon: `/etc/init.d/munin-node restart`.
5. Done. You should now start to see the charts on the Munin pages.
6. Done. You should now start to see the charts on the Munin pages.
## Localization
@@ -105,13 +110,14 @@ You can split the graphs of your fritzbox from the localhost graphs by following
1. Use the following as your host configuration in `/etc/munin/munin.conf`
[home.yourhost.net;server]
address 127.0.0.1
use_node_name yes
[home.yourhost.net;server]
address 127.0.0.1
use_node_name yes
[home.yourhost.net;fritzbox]
address 127.0.0.1
use_node_name no
[home.yourhost.net;fritzbox]
address 127.0.0.1
use_node_name no
2. Add the following to your munin-node configuration

View File

@@ -27,26 +27,26 @@ def print_values():
sys.exit("Couldn't get connection uptime")
uptime = conn.call_action('WANIPConnection', 'GetStatusInfo')['NewUptime']
print ('uptime.value %.2f' % (int(uptime) / 86400.0))
print('uptime.value %.2f' % (int(uptime) / 86400.0))
def print_config():
print "graph_title AVM Fritz!Box Connection Uptime"
print "graph_args --base 1000 -l 0"
print 'graph_vlabel uptime in days'
print "graph_scale no'"
print "graph_category network"
print "uptime.label uptime"
print "uptime.draw AREA"
print("graph_title AVM Fritz!Box Connection Uptime")
print("graph_args --base 1000 -l 0")
print('graph_vlabel uptime in days')
print("graph_scale no'")
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']
print("host_name " + os.environ['host_name'])
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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'):
try:
print_values()

View File

@@ -31,34 +31,34 @@ def get_cpu_temperature():
server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
sid = fh.get_sid(server, password)
data = fh.get_page(server, sid, PAGE)
session_id = fh.get_session_id(server, password)
data = fh.get_page_content(server, session_id, PAGE)
m = re.search(pattern, data)
if m:
print 'temp.value %d' % (int(m.group(1)))
print('temp.value %d' % (int(m.group(1))))
def print_config():
print "graph_title AVM Fritz!Box CPU temperature"
print "graph_vlabel degrees Celsius"
print "graph_category sensors"
print "graph_order tmp"
print "graph_scale no"
print "temp.label CPU temperature"
print "temp.type GAUGE"
print "temp.graph LINE1"
print "temp.min 0"
print "temp.info Fritzbox CPU temperature"
print("graph_title AVM Fritz!Box CPU temperature")
print("graph_vlabel degrees Celsius")
print("graph_category sensors")
print("graph_order tmp")
print("graph_scale no")
print("temp.label CPU temperature")
print("temp.type GAUGE")
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']
print("host_name " + os.environ['host_name'])
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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':
# Some docs say it'll be called with fetch, some say no arg at all
try:

View File

@@ -31,25 +31,25 @@ def get_cpu_usage():
server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
sid = fh.get_sid(server, password)
data = fh.get_page(server, sid, PAGE)
session_id = fh.get_session_id(server, password)
data = fh.get_page_content(server, session_id, PAGE)
m = re.search(pattern, data)
if m:
print 'cpu.value %d' % (int(m.group(1)))
print('cpu.value %d' % (int(m.group(1))))
def print_config():
print "graph_title AVM Fritz!Box CPU usage"
print "graph_vlabel %"
print "graph_category system"
print "graph_order cpu"
print "graph_scale no"
print "cpu.label system"
print "cpu.type GAUGE"
print "cpu.graph AREA"
print "cpu.min 0"
print "cpu.info Fritzbox CPU usage"
print("graph_title AVM Fritz!Box CPU usage")
print("graph_vlabel %")
print("graph_category system")
print("graph_order cpu")
print("graph_scale no")
print("cpu.label system")
print("cpu.type GAUGE")
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']
@@ -58,7 +58,7 @@ if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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':
# Some docs say it'll be called with fetch, some say no arg at all
try:

View File

@@ -14,80 +14,94 @@
This plugin supports the following munin configuration parameters:
#%# family=auto contrib
#%# capabilities=autoconf
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
framp at linux-tips-and-tricks dot de
"""
import hashlib
import httplib
import re
import sys
from xml.dom import minidom
USER_AGENT = "Mozilla/5.0 (U; Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
import requests
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_sid(server, password, port=80):
"""Obtains the sid after login into the fritzbox"""
conn = httplib.HTTPConnection(server + ':' + str(port))
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
:param password: the password to log into the Fritzbox webinterface
:param port: the port the Fritzbox webserver runs on
:return: the session id
"""
headers = {"Accept": "application/xml",
"Content-Type": "text/plain",
"User-Agent": USER_AGENT}
initial_page = '/login_sid.lua'
conn.request("GET", initial_page, '', headers)
response = conn.getresponse()
data = response.read()
if response.status != 200:
print "%s %s" % (response.status, response.reason)
sys.exit(0)
url = 'http://{}:{}/login_sid.lua'.format(server, port)
try:
r = requests.get(url, headers=headers)
r.raise_for_status()
except requests.exceptions.HTTPError as err:
print(err)
sys.exit(1)
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)).decode('iso-8859-1').encode('utf-16le')
m = hashlib.md5()
m.update(challenge_bf)
response_bf = '{}-{}'.format(challenge, m.hexdigest().lower())
else:
xml_data = minidom.parseString(data)
sid_info = xml_data.getElementsByTagName('SID')
sid = sid_info[0].firstChild.data
if sid == "0000000000000000":
challenge_info = xml_data.getElementsByTagName('Challenge')
challenge = challenge_info[0].firstChild.data
challenge_bf = (challenge + '-' + password).decode('iso-8859-1').encode('utf-16le')
m = hashlib.md5()
m.update(challenge_bf)
response_bf = challenge + '-' + m.hexdigest().lower()
else:
return sid
return session_id
headers = {"Accept": "text/html,application/xhtml+xml,application/xml",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": USER_AGENT}
login_page = "/login_sid.lua?&response=" + response_bf
conn.request("GET", login_page, '', headers)
response = conn.getresponse()
data = response.read()
if response.status != 200:
print "%s %s" % (response.status, response.reason)
url = 'http://{}:{}/login_sid.lua?&response={}'.format(server, port, response_bf)
try:
r = requests.get(url, headers=headers)
r.raise_for_status()
except requests.exceptions.HTTPError as err:
print(err)
sys.exit(1)
root = etree.fromstring(r.content)
session_id = root.xpath('//SessionInfo/SID/text()')[0]
if session_id == "0000000000000000":
print("ERROR - No SID received because of invalid password")
sys.exit(0)
else:
sid = re.search("<SID>(.*?)</SID>", data).group(1)
if sid == "0000000000000000":
print "ERROR - No SID received because of invalid password"
sys.exit(0)
return sid
return session_id
def get_page(server, sid, page, port=80):
"""Fetches a page from the Fritzbox and returns its content"""
conn = httplib.HTTPConnection(server + ':' + str(port))
def get_page_content(server, session_id, page, port=80):
"""Fetches a page from the Fritzbox and returns its content
:param server: the ip address of the Fritzbox
:param session_id: a valid session id
:param page: the page you are regquesting
:param port: the port the Fritzbox webserver runs on
:return: the content of the page
"""
headers = {"Accept": "application/xml",
"Content-Type": "text/plain",
"User-Agent": USER_AGENT}
page_with_sid = page + "?sid=" + sid
conn.request("GET", page_with_sid, '', headers)
response = conn.getresponse()
data = response.read()
if response.status != 200:
print "%s %s" % (response.status, response.reason)
print data
sys.exit(0)
else:
return data
url = 'http://{}:{}/{}?sid={}'.format(server, port, page, session_id)
try:
r = requests.get(url, headers=headers)
r.raise_for_status()
except requests.exceptions.HTTPError as err:
print(err)
sys.exit(1)
return r.content

View File

@@ -32,41 +32,41 @@ def get_memory_usage():
server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
sid = fh.get_sid(server, password)
data = fh.get_page(server, sid, PAGE)
session_id = fh.get_session_id(server, password)
data = fh.get_page_content(server, session_id, PAGE)
matches = re.finditer(pattern, data)
if matches:
data = zip(USAGE, [m.group(1) for m in matches])
for d in data:
print'%s.value %s' % (d[0], d[1])
print('%s.value %s' % (d[0], d[1]))
def print_config():
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"
print "graph_order strict cache free"
print "graph_info This graph shows what the Fritzbox uses memory for."
print "graph_scale no"
print "strict.label strict"
print "strict.type GAUGE"
print "strict.draw AREA"
print "cache.label cache"
print "cache.type GAUGE"
print "cache.draw STACK"
print "free.label free"
print "free.type GAUGE"
print "free.draw STACK"
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")
print("graph_order strict cache free")
print("graph_info This graph shows what the Fritzbox uses memory for.")
print("graph_scale no")
print("strict.label strict")
print("strict.type GAUGE")
print("strict.draw AREA")
print("cache.label cache")
print("cache.type GAUGE")
print("cache.draw STACK")
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']
print("host_name " + os.environ['host_name'])
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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':
# Some docs say it'll be called with fetch, some say no arg at all
try:

View File

@@ -32,65 +32,65 @@ def get_power_consumption():
server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
sid = fh.get_sid(server, password)
data = fh.get_page(server, sid, PAGE)
session_id = fh.get_session_id(server, password)
data = fh.get_page_content(server, session_id, PAGE)
matches = re.finditer(pattern, data)
if matches:
data = zip(DEVICES, [m.group(4) for m in matches])
for d in data:
print'%s.value %s' % (d[0], d[1])
print('%s.value %s' % (d[0], d[1]))
def print_config():
print "graph_title AVM Fritz!Box Power Consumption"
print "graph_vlabel %"
print "graph_category system"
print "graph_order system cpu wifi dsl ab usb"
print "system.label system"
print "system.type GAUGE"
print "system.graph LINE12"
print "system.min 0"
print "system.max 100"
print "system.info Fritzbox overall power consumption"
print "cpu.label cpu"
print "cpu.type GAUGE"
print "cpu.graph LINE1"
print "cpu.min 0"
print "cpu.max 100"
print "cpu.info Fritzbox central processor power consumption"
print "wifi.label wifi"
print "wifi.type GAUGE"
print "wifi.graph LINE1"
print "wifi.min 0"
print "wifi.max 100"
print "wifi.info Fritzbox wifi power consumption"
print "dsl.label dsl"
print "dsl.type GAUGE"
print "dsl.graph LINE1"
print "dsl.min 0"
print "dsl.max 100"
print "dsl.info Fritzbox dsl power consumption"
print "ab.label ab"
print "ab.type GAUGE"
print "ab.graph LINE1"
print "ab.min 0"
print "ab.max 100"
print "ab.info Fritzbox analog phone ports power consumption"
print "usb.label usb"
print "usb.type GAUGE"
print "usb.graph LINE1"
print "usb.min 0"
print "usb.max 100"
print "usb.info Fritzbox usb devices power consumption"
print("graph_title AVM Fritz!Box Power Consumption")
print("graph_vlabel %")
print("graph_category system")
print("graph_order system cpu wifi dsl ab usb")
print("system.label system")
print("system.type GAUGE")
print("system.graph LINE12")
print("system.min 0")
print("system.max 100")
print("system.info Fritzbox overall power consumption")
print("cpu.label cpu")
print("cpu.type GAUGE")
print("cpu.graph LINE1")
print("cpu.min 0")
print("cpu.max 100")
print("cpu.info Fritzbox central processor power consumption")
print("wifi.label wifi")
print("wifi.type GAUGE")
print("wifi.graph LINE1")
print("wifi.min 0")
print("wifi.max 100")
print("wifi.info Fritzbox wifi power consumption")
print("dsl.label dsl")
print("dsl.type GAUGE")
print("dsl.graph LINE1")
print("dsl.min 0")
print("dsl.max 100")
print("dsl.info Fritzbox dsl power consumption")
print("ab.label ab")
print("ab.type GAUGE")
print("ab.graph LINE1")
print("ab.min 0")
print("ab.max 100")
print("ab.info Fritzbox analog phone ports power consumption")
print("usb.label usb")
print("usb.type GAUGE")
print("usb.graph LINE1")
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']
print("host_name " + os.environ['host_name'])
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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':
# Some docs say it'll be called with fetch, some say no arg at all
try:

View File

@@ -27,59 +27,59 @@ def print_values():
sys.exit("Couldn't get WAN traffic")
down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesReceived')['NewTotalBytesReceived']
print ('down.value %d' % down_traffic)
print('down.value %d' % down_traffic)
up_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesSent')['NewTotalBytesSent']
print ('up.value %d' % up_traffic)
print('up.value %d' % up_traffic)
if not os.environ.get('traffic_remove_max'):
max_down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')[
'NewLayer1DownstreamMaxBitRate']
print ('maxdown.value %d' % max_down_traffic)
print('maxdown.value %d' % max_down_traffic)
max_up_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')[
'NewLayer1UpstreamMaxBitRate']
print ('maxup.value %d' % max_up_traffic)
print('maxup.value %d' % max_up_traffic)
def print_config():
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"
print "graph_order down up maxdown maxup"
print "down.label received"
print "down.type DERIVE"
print "down.graph no"
print "down.cdef down,8,*"
print "down.min 0"
print "down.max 1000000000"
print "up.label bps"
print "up.type DERIVE"
print "up.draw AREA"
print "up.cdef up,8,*"
print "up.min 0"
print "up.max 1000000000"
print "up.negative down"
print "up.info Traffic of the WAN interface."
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")
print("graph_order down up maxdown maxup")
print("down.label received")
print("down.type DERIVE")
print("down.graph no")
print("down.cdef down,8,*")
print("down.min 0")
print("down.max 1000000000")
print("up.label bps")
print("up.type DERIVE")
print("up.draw AREA")
print("up.cdef up,8,*")
print("up.min 0")
print("up.max 1000000000")
print("up.negative down")
print("up.info Traffic of the WAN interface.")
if not os.environ.get('traffic_remove_max'):
print "maxdown.label received"
print "maxdown.type GAUGE"
print "maxdown.graph no"
print "maxup.label MAX"
print "maxup.type GAUGE"
print "maxup.negative maxdown"
print "maxup.draw LINE1"
print "maxup.info Maximum speed of the WAN interface."
print("maxdown.label received")
print("maxdown.type GAUGE")
print("maxdown.graph no")
print("maxup.label MAX")
print("maxup.type GAUGE")
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']
print("host_name " + os.environ['host_name'])
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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'):
try:
print_values()

View File

@@ -39,8 +39,8 @@ def get_uptime():
server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
sid = fh.get_sid(server, password)
data = fh.get_page(server, sid, PAGE)
session_id = fh.get_session_id(server, password)
data = fh.get_page_content(server, session_id, PAGE)
matches = re.finditer(pattern, data)
if matches:
hours = 0.0
@@ -56,22 +56,22 @@ def get_uptime():
def print_config():
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"
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']
print("host_name " + os.environ['host_name'])
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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':
# Some docs say it'll be called with fetch, some say no arg at all
try:

View File

@@ -35,33 +35,33 @@ def get_connected_wifi_devices():
server = os.environ['fritzbox_ip']
password = os.environ['fritzbox_password']
sid = fh.get_sid(server, password)
data = fh.get_page(server, sid, PAGE)
session_id = fh.get_session_id(server, password)
data = fh.get_page_content(server, session_id, PAGE)
m = re.search(pattern, data)
if m:
connected_devices = int(m.group(1))
print 'wifi.value %d' % connected_devices
print('wifi.value %d' % connected_devices)
def print_config():
print 'graph_title AVM Fritz!Box Connected Wifi Devices'
print 'graph_vlabel Number of devices'
print 'graph_args --base 1000'
print 'graph_category network'
print 'graph_order wifi'
print 'wifi.label Wifi Connections on 2.4 & 5 Ghz'
print 'wifi.type GAUGE'
print 'wifi.graph LINE1'
print 'wifi.info Wifi Connections on 2.4 & 5 Ghz'
print('graph_title AVM Fritz!Box Connected Wifi Devices')
print('graph_vlabel Number of devices')
print('graph_args --base 1000')
print('graph_category network')
print('graph_order wifi')
print('wifi.label Wifi Connections on 2.4 & 5 Ghz')
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']
print("host_name " + os.environ['host_name'])
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
print_config()
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':
# Some docs say it'll be called with fetch, some say no arg at all
try: