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

Merge f0d43e8168201dad5902f841dd0699554911aeef into 2a1185612ea675c9a3cabc1a35bb1c44f76b0966

This commit is contained in:
Christoph Wempe 2017-03-02 23:44:55 +00:00 committed by GitHub
commit 6ea9be4040
10 changed files with 73 additions and 8 deletions

View File

@ -63,6 +63,7 @@ If you are using FRITZ!OS 6.30 use the master branch.
[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>
3. Create symbolic links to /etc/munin/plugins. 3. Create symbolic links to /etc/munin/plugins.
@ -75,3 +76,19 @@ If you are using FRITZ!OS 6.30 use the master branch.
Do not forget to restart the munin-node daemon as described in step Do not forget to restart the munin-node daemon as described in step
3 of the installation instructions above. 3 of the installation instructions above.
## Multiple Fritz!Boxes
To generate graphs for additional boxes create new symbolic links (like in step 3) but chgange the first part of th
e.g.: ```ln -s /usr/share/munin/plugins/fritzbox_uptime.py /etc/munin/plugins/freetz_uptime```
And create a new section in ```/etc/munin/plugin-cond.d/munin-node``` with the alternative name.
```
[freetz_*]
env.fritzbox_ip <ip_address_to_your_second_fritzbox>
env.fritzbox_username <fritzbox_username>
env.fritzbox_password <fritzbox_password>
```
Restart the munin-node daemon.

View File

@ -19,6 +19,9 @@ import sys
from fritzconnection import FritzConnection from fritzconnection import FritzConnection
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
def print_values(): def print_values():
try: try:
@ -31,6 +34,7 @@ def print_values():
def print_config(): def print_config():
print "host_name %s" % boxname
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'

View File

@ -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:
@ -24,14 +25,18 @@ import fritzbox_helper as fh
PAGE = '/system/ecostat.lua' PAGE = '/system/ecostat.lua'
pattern = re.compile('Query\s=\s"(\d{1,3})') pattern = re.compile('Query\s=\s"(\d{1,3})')
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
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']
username = os.getenv('fritzbox_username', "None")
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)
@ -40,6 +45,7 @@ def get_cpu_temperature():
def print_config(): def print_config():
print "host_name %s" % boxname
print "graph_title AVM Fritz!Box CPU temperature" print "graph_title AVM Fritz!Box CPU temperature"
print "graph_vlabel degrees Celsius" print "graph_vlabel degrees Celsius"
print "graph_category sensors" print "graph_category sensors"

View File

@ -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:
@ -24,14 +25,18 @@ import fritzbox_helper as fh
PAGE = '/system/ecostat.lua' PAGE = '/system/ecostat.lua'
pattern = re.compile('Query1\s=\s"(\d{1,3})') pattern = re.compile('Query1\s=\s"(\d{1,3})')
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
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']
username = os.getenv('fritzbox_username', "None")
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)
@ -40,6 +45,7 @@ def get_cpu_usage():
def print_config(): def print_config():
print "host_name %s" % boxname
print "graph_title AVM Fritz!Box CPU usage" print "graph_title AVM Fritz!Box CPU usage"
print "graph_vlabel %" print "graph_vlabel %"
print "graph_category system" print "graph_category system"

View File

@ -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,10 @@ 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 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()
@ -69,6 +72,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

View File

@ -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:
@ -25,14 +26,18 @@ PAGE = '/system/ecostat.lua'
pattern = re.compile('Query[1-3]\s="(\d{1,3})') pattern = re.compile('Query[1-3]\s="(\d{1,3})')
USAGE = ['free', 'cache', 'strict'] USAGE = ['free', 'cache', 'strict']
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
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']
username = os.getenv('fritzbox_username', "None")
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:
@ -42,6 +47,7 @@ def get_memory_usage():
def print_config(): def print_config():
print "host_name %s" % boxname
print "graph_title AVM Fritz!Box Memory" print "graph_title AVM Fritz!Box Memory"
print "graph_vlabel %" print "graph_vlabel %"
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100" print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100"

View File

@ -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:
@ -25,14 +26,18 @@ PAGE = '/system/energy.lua'
pattern = re.compile('<td>(.+?)"bar\s(act|fillonly)"(.+?)\s(\d{1,3})\s%') pattern = re.compile('<td>(.+?)"bar\s(act|fillonly)"(.+?)\s(\d{1,3})\s%')
DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb'] DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
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']
username = os.getenv('fritzbox_username', "None")
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:
@ -42,6 +47,7 @@ def get_power_consumption():
def print_config(): def print_config():
print "host_name %s" % boxname
print "graph_title AVM Fritz!Box Power Consumption" print "graph_title AVM Fritz!Box Power Consumption"
print "graph_vlabel %" print "graph_vlabel %"
print "graph_category network" print "graph_category network"

View File

@ -19,6 +19,9 @@ import sys
from fritzconnection import FritzConnection from fritzconnection import FritzConnection
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
def print_values(): def print_values():
try: try:
@ -42,6 +45,7 @@ def print_values():
def print_config(): def print_config():
print "host_name %s" % boxname
print "graph_title AVM Fritz!Box WAN traffic" print "graph_title AVM Fritz!Box WAN traffic"
print "graph_args --base 1000" print "graph_args --base 1000"
print "graph_vlabel bits in (-) / out (+) per \${graph_period}" print "graph_vlabel bits in (-) / out (+) per \${graph_period}"

View File

@ -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:
@ -24,14 +25,18 @@ import fritzbox_helper as fh
PAGE = '/system/energy.lua' PAGE = '/system/energy.lua'
pattern = re.compile("(\d+)\s(Tag|Stunden|Minuten)") pattern = re.compile("(\d+)\s(Tag|Stunden|Minuten)")
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
def get_uptime(): def get_uptime():
"""get the current uptime""" """get the current uptime"""
server = os.environ['fritzbox_ip'] server = os.environ['fritzbox_ip']
username = os.getenv('fritzbox_username', "None")
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:
@ -48,6 +53,7 @@ def get_uptime():
def print_config(): def print_config():
print "host_name %s" % boxname
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'

View File

@ -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:
@ -24,14 +25,18 @@ import fritzbox_helper as fh
PAGE = '/system/energy.lua' PAGE = '/system/energy.lua'
pattern = re.compile("(\d+) WLAN") pattern = re.compile("(\d+) WLAN")
# bet box name from first part before '_' in (symlink) file name
boxname = os.path.basename(__file__).rsplit('_')[0]
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']
username = os.getenv('fritzbox_username', "None")
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:
@ -40,6 +45,7 @@ def get_connected_wifi_devices():
def print_config(): def print_config():
print "host_name %s" % boxname
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'