mirror of
https://github.com/Tafkas/fritzbox-munin.git
synced 2023-10-10 13:36:55 +02:00
commit
c1ea899479
93
README.md
93
README.md
@ -1,26 +1,9 @@
|
|||||||
# fritzbox-munin
|
# fritzbox-munin
|
||||||
|
|
||||||
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.
|
A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a [FRITZ!Box 7490](http://geni.us/OO2c7S)(Amazon link) running FRITZ!OS 07.12.
|
||||||
|
|
||||||
If you are using the scripts on a different Fritz!Box model please let me know by
|
If you are using the scripts on a different Fritz!Box model please let me know by
|
||||||
|
|
||||||
- opening an issue
|
|
||||||
- submitting a pull request
|
|
||||||
|
|
||||||
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 7560](http://geni.us/6gPZNI)
|
|
||||||
- [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).
|
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
These python scripts are [Munin](http://munin-monitoring.org) plugins for monitoring the [Fritz!Box](http://avm.de/produkte/fritzbox/) router by AVM.
|
These python scripts are [Munin](http://munin-monitoring.org) plugins for monitoring the [Fritz!Box](http://avm.de/produkte/fritzbox/) router by AVM.
|
||||||
@ -74,25 +57,61 @@ If you are using the scripts on a different Fritz!Box model please let me know b
|
|||||||
1. 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
|
1. 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 fritzconnection
|
||||||
pip install requests
|
pip install lxml
|
||||||
|
|
||||||
2. Make sure the FritzBox has UPnP status information enabled. (German interface: Heimnetz > Heimnetzübersicht > Netzwerkeinstellungen > Statusinformationen über UPnP übertragen)
|
2. Make sure the FritzBox has UPnP status information enabled. (German interface: Heimnetz > Heimnetzübersicht > Netzwerkeinstellungen > Statusinformationen über UPnP übertragen)
|
||||||
|
|
||||||
3. Copy all the scripts to `/usr/share/munin/plugins`
|
3. Copy all the scripts (*.py) to `/usr/share/munin/plugins`
|
||||||
|
|
||||||
4. Create entry in `/etc/munin/plugin-conf.d/munin-node`:
|
4. Make all the scripts execute able (chmod 755 /usr/share/munin/plugins.*py)
|
||||||
|
|
||||||
|
5. Create entry in `/etc/munin/plugin-conf.d/munin-node`:
|
||||||
|
1. only one fritzbox or all fritzboxes use the same password:
|
||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_ip <ip_address_to_your_fritzbox>
|
|
||||||
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
|
|
||||||
|
|
||||||
5. Create symbolic links to `/etc/munin/plugins`.
|
2. multiple fritzboxes:
|
||||||
|
|
||||||
6. Restart the munin-node daemon: `/etc/init.d/munin-node restart`.
|
[fritzbox_<fqdn1>_*]
|
||||||
|
env.fritzbox_password <fritzbox_password>
|
||||||
|
env.traffic_remove_max true # if you do not want the possible max values
|
||||||
|
|
||||||
7. Done. You should now start to see the charts on the Munin pages.
|
[fritzbox_<fqdn2>_*]
|
||||||
|
env.fritzbox_password <fritzbox_password>
|
||||||
|
env.traffic_remove_max true # if you do not want the possible max values
|
||||||
|
|
||||||
|
6. Create symbolic link in `/etc/munin/plugins` for `fritzbox_helper.py`.
|
||||||
|
|
||||||
|
cd /etc/munin/plugins
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox_helper.py fritzbox_helper.py
|
||||||
|
|
||||||
|
7. Create symbolic link in `/etc/munin/plugins` for probes.
|
||||||
|
|
||||||
|
link `/usr/share/munin/plugins/fritzbox__<probe>.py` to `fritzbox_<fqdn>_<probe>`
|
||||||
|
|
||||||
|
example
|
||||||
|
cd /etc/munin/plugins
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_usage.py fritzbox_fritz.box_cpu_usage
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_temperature.py fritzbox_fritz.box_cpu_temperature
|
||||||
|
...
|
||||||
|
|
||||||
|
if you have multiple fritz box just create multiple sets of links with a different fqdn or ip.
|
||||||
|
|
||||||
|
example
|
||||||
|
cd /etc/munin/plugins
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_usage.py fritzbox_fritz.box_cpu_usage
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_usage.py fritzbox_box2.fritz.box_cpu_usage
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_usage.py fritzbox_192.168.100.1_cpu_usage
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_temperature.py fritzbox_box2.fritz.box_cpu_temperature
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_temperature.py fritzbox_box2.fritz.box_cpu_temperature
|
||||||
|
ln -d /usr/share/munin/plugins/fritzbox__cpu_temperature.py fritzbox_192.168.100.1_cpu_temperature
|
||||||
|
...
|
||||||
|
|
||||||
|
8. Restart the munin-node daemon: `systemctl restart munin-node`.
|
||||||
|
|
||||||
|
9. Done. You should now start to see the charts on the Munin pages.
|
||||||
|
|
||||||
## Localization
|
## Localization
|
||||||
|
|
||||||
@ -106,26 +125,22 @@ You can change the used locale by setting an environment variable in your plugin
|
|||||||
|
|
||||||
env.locale en
|
env.locale en
|
||||||
|
|
||||||
## Different hosts for the fritzbox and your system
|
## Set a group for your fritzboxes
|
||||||
|
|
||||||
You can split the graphs of your fritzbox from the localhost graphs by following the next steps:
|
You can group the graphs of your fritzbox:
|
||||||
|
|
||||||
1. Use the following as your host configuration in `/etc/munin/munin.conf`
|
1. Use the following as your host configuration in `/etc/munin/munin.conf` or by creating a file in `/etc/munin/munin-conf.d`
|
||||||
|
|
||||||
[home.yourhost.net;server]
|
[<groupname>;<fqdn>]
|
||||||
address 127.0.0.1
|
|
||||||
use_node_name yes
|
|
||||||
|
|
||||||
|
|
||||||
[home.yourhost.net;fritzbox]
|
|
||||||
address 127.0.0.1
|
address 127.0.0.1
|
||||||
use_node_name no
|
use_node_name no
|
||||||
|
|
||||||
2. Add the following to your munin-node configuration
|
example:
|
||||||
|
[Network;fritz.box]
|
||||||
|
address 127.0.0.1
|
||||||
|
use_node_name no
|
||||||
|
|
||||||
env.host_name fritzbox
|
2. Restart your munin-node: `systemctl restart munin-node`
|
||||||
|
|
||||||
3. Restart your munin-node: `systemctl restart munin-node`
|
|
||||||
|
|
||||||
## Environment Settings
|
## Environment Settings
|
||||||
|
|
||||||
|
6
fritzbox_connection_uptime.py → fritzbox__connection_uptime.py
Executable file → Normal file
6
fritzbox_connection_uptime.py → fritzbox__connection_uptime.py
Executable file → Normal file
@ -24,11 +24,12 @@ import sys
|
|||||||
|
|
||||||
from fritzconnection.lib.fritzstatus import FritzStatus
|
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||||
|
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
def print_values():
|
def print_values():
|
||||||
try:
|
try:
|
||||||
conn = FritzStatus(address=os.environ['fritzbox_ip'], password=os.environ['fritzbox_password'])
|
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
sys.exit("Couldn't get connection uptime")
|
sys.exit("Couldn't get connection uptime")
|
||||||
|
|
||||||
uptime = conn.uptime
|
uptime = conn.uptime
|
||||||
@ -36,6 +37,7 @@ def print_values():
|
|||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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 hours')
|
print('graph_vlabel uptime in hours')
|
4
fritzbox_cpu_temperature.py → fritzbox__cpu_temperature.py
Executable file → Normal file
4
fritzbox_cpu_temperature.py → fritzbox__cpu_temperature.py
Executable file → Normal file
@ -21,12 +21,13 @@ import sys
|
|||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
PAGE = 'ecoStat'
|
PAGE = 'ecoStat'
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_temperature():
|
def get_cpu_temperature():
|
||||||
"""get the current cpu temperature"""
|
"""get the current cpu temperature"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = hostname
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, password)
|
||||||
@ -36,6 +37,7 @@ def get_cpu_temperature():
|
|||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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")
|
4
fritzbox_cpu_usage.py → fritzbox__cpu_usage.py
Executable file → Normal file
4
fritzbox_cpu_usage.py → fritzbox__cpu_usage.py
Executable file → Normal file
@ -21,12 +21,13 @@ import sys
|
|||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
PAGE = 'ecoStat'
|
PAGE = 'ecoStat'
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_usage():
|
def get_cpu_usage():
|
||||||
"""get the current cpu usage"""
|
"""get the current cpu usage"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = hostname
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, password)
|
||||||
@ -36,6 +37,7 @@ def get_cpu_usage():
|
|||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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")
|
4
fritzbox_memory_usage.py → fritzbox__memory_usage.py
Executable file → Normal file
4
fritzbox_memory_usage.py → fritzbox__memory_usage.py
Executable file → Normal file
@ -22,12 +22,13 @@ import fritzbox_helper as fh
|
|||||||
|
|
||||||
PAGE = 'ecoStat'
|
PAGE = 'ecoStat'
|
||||||
USAGE = ['strict', 'cache', 'free']
|
USAGE = ['strict', 'cache', 'free']
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
|
|
||||||
def get_memory_usage():
|
def get_memory_usage():
|
||||||
"""get the current memory usage"""
|
"""get the current memory usage"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = hostname
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, password)
|
||||||
@ -38,6 +39,7 @@ def get_memory_usage():
|
|||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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")
|
5
fritzbox_power_consumption.py → fritzbox__power_consumption.py
Executable file → Normal file
5
fritzbox_power_consumption.py → fritzbox__power_consumption.py
Executable file → Normal file
@ -24,12 +24,12 @@ import fritzbox_helper as fh
|
|||||||
|
|
||||||
PAGE = 'energy'
|
PAGE = 'energy'
|
||||||
DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
|
DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
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 = hostname
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, password)
|
||||||
@ -41,6 +41,7 @@ def get_power_consumption():
|
|||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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 system")
|
print("graph_category system")
|
23
fritzbox_traffic.py → fritzbox__traffic.py
Executable file → Normal file
23
fritzbox_traffic.py → fritzbox__traffic.py
Executable file → Normal file
@ -24,15 +24,18 @@ import sys
|
|||||||
|
|
||||||
from fritzconnection.lib.fritzstatus import FritzStatus
|
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||||
|
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
def print_values():
|
def print_values():
|
||||||
try:
|
try:
|
||||||
conn = FritzStatus(address=os.environ['fritzbox_ip'], password=os.environ['fritzbox_password'])
|
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
sys.exit("Couldn't get WAN traffic")
|
sys.exit("Couldn't get WAN traffic")
|
||||||
|
|
||||||
traffic = conn.transmission_rate
|
traffic = conn.transmission_rate
|
||||||
up = traffic[0]
|
up = traffic[0]*8
|
||||||
down = traffic[1]
|
down = traffic[1]*8
|
||||||
print('down.value %d' % down)
|
print('down.value %d' % down)
|
||||||
|
|
||||||
print('up.value %d' % up)
|
print('up.value %d' % up)
|
||||||
@ -46,29 +49,31 @@ def print_values():
|
|||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
try:
|
try:
|
||||||
conn = FritzStatus(address=os.environ['fritzbox_ip'], password=os.environ['fritzbox_password'])
|
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
sys.exit("Couldn't get WAN traffic")
|
sys.exit("Couldn't get WAN traffic")
|
||||||
|
|
||||||
max_traffic = conn.max_bit_rate
|
max_traffic = conn.max_bit_rate
|
||||||
|
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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 bit up (-) / down (+) per ${graph_period}")
|
print("graph_vlabel bit up (+) / down (-) per ${graph_period}")
|
||||||
print("graph_category network")
|
print("graph_category network")
|
||||||
print("graph_order down up maxdown maxup")
|
print("graph_order down up maxdown maxup")
|
||||||
print("down.label received")
|
print("down.label received")
|
||||||
print("down.type DERIVE")
|
print("down.type GAUGE")
|
||||||
print("down.graph no")
|
print("down.graph no")
|
||||||
print("down.cdef down,8,*")
|
#print("down.cdef down,8,*")
|
||||||
print("down.min 0")
|
print("down.min 0")
|
||||||
print("down.max %d" % max_traffic[1])
|
print("down.max %d" % max_traffic[1])
|
||||||
#print("down.warning %.0f" % (max_traffic[1]*0.6))
|
#print("down.warning %.0f" % (max_traffic[1]*0.6))
|
||||||
#print("down.critical %.0f" % (max_traffic[1]*0.8))
|
#print("down.critical %.0f" % (max_traffic[1]*0.8))
|
||||||
print("up.label bps")
|
print("up.label bps")
|
||||||
print("up.type DERIVE")
|
print("up.type GAUGE")
|
||||||
print("up.draw AREA")
|
print("up.draw AREA")
|
||||||
print("up.cdef up,8,*")
|
#print("up.cdef up,8,*")
|
||||||
print("up.min 0")
|
print("up.min 0")
|
||||||
print("up.max %d" % max_traffic[0])
|
print("up.max %d" % max_traffic[0])
|
||||||
print("up.negative down")
|
print("up.negative down")
|
92
fritzbox__traffic_down.py
Normal file
92
fritzbox__traffic_down.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
fritzbox_traffic - A munin plugin for Linux to monitor AVM Fritzbox WAN traffic
|
||||||
|
Copyright (C) 2015 Christian Stade-Schuldt
|
||||||
|
Author: Christian Stade-Schuldt
|
||||||
|
|
||||||
|
Updated to fritzconnection library version 1.3.1
|
||||||
|
Copyright (C) 2020 Oliver Edelamnn
|
||||||
|
Author: Oliver Edelmann
|
||||||
|
|
||||||
|
Like Munin, this plugin is licensed under the GNU GPL v2 license
|
||||||
|
http://www.opensource.org/licenses/GPL-2.0
|
||||||
|
Like Munin, this plugin is licensed under the GNU GPL v2 license
|
||||||
|
http://www.opensource.org/licenses/GPL-2.0
|
||||||
|
This plugin requires the fritzconnection plugin. To install it using pip:
|
||||||
|
pip install fritzconnection
|
||||||
|
This plugin supports the following munin configuration parameters:
|
||||||
|
#%# family=auto contrib
|
||||||
|
#%# capabilities=autoconf
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||||
|
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
|
def print_values():
|
||||||
|
try:
|
||||||
|
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit("Couldn't get WAN traffic")
|
||||||
|
|
||||||
|
traffic = conn.transmission_rate
|
||||||
|
up = traffic[0]*8
|
||||||
|
down = traffic[1]*8
|
||||||
|
print('down.value %d' % down)
|
||||||
|
|
||||||
|
print('up.value %d' % up)
|
||||||
|
|
||||||
|
if not os.environ.get('traffic_remove_max') or "false" in os.environ.get('traffic_remove_max'):
|
||||||
|
max_traffic = conn.max_bit_rate
|
||||||
|
print('maxdown.value %d' % max_traffic[1])
|
||||||
|
|
||||||
|
print('maxup.value %d' % max_traffic[0])
|
||||||
|
|
||||||
|
|
||||||
|
def print_config():
|
||||||
|
try:
|
||||||
|
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit("Couldn't get WAN traffic")
|
||||||
|
|
||||||
|
max_traffic = conn.max_bit_rate
|
||||||
|
|
||||||
|
print("host_name %s" % hostname)
|
||||||
|
print("graph_title AVM Fritz!Box WAN traffic")
|
||||||
|
print("graph_args --base 1000")
|
||||||
|
print("graph_vlabel bit down per ${graph_period}")
|
||||||
|
print("graph_category network")
|
||||||
|
print("graph_order down maxdown")
|
||||||
|
print("down.label bps")
|
||||||
|
print("down.type GAUGE")
|
||||||
|
print("down.draw AREA")
|
||||||
|
print("down.graph no")
|
||||||
|
print("down.min 0")
|
||||||
|
print("down.max %d" % max_traffic[1])
|
||||||
|
print("down.warning %.0f" % (max_traffic[1]*0.6))
|
||||||
|
print("down.critical %.0f" % (max_traffic[1]*0.8))
|
||||||
|
print("down.info Traffic of the WAN interface.")
|
||||||
|
if not os.environ.get('traffic_remove_max') or "false" in os.environ.get('traffic_remove_max'):
|
||||||
|
print("maxdown.label received")
|
||||||
|
print("maxdown.type GAUGE")
|
||||||
|
print("maxdown.graph no")
|
||||||
|
print("maxdown.info Maximum down speed of the WAN interface.")
|
||||||
|
if os.environ.get('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
|
||||||
|
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
||||||
|
try:
|
||||||
|
print_values()
|
||||||
|
except:
|
||||||
|
sys.exit("Couldn't retrieve fritzbox traffic")
|
91
fritzbox__traffic_up.py
Normal file
91
fritzbox__traffic_up.py
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
fritzbox_traffic - A munin plugin for Linux to monitor AVM Fritzbox WAN traffic
|
||||||
|
Copyright (C) 2015 Christian Stade-Schuldt
|
||||||
|
Author: Christian Stade-Schuldt
|
||||||
|
|
||||||
|
Updated to fritzconnection library version 1.3.1
|
||||||
|
Copyright (C) 2020 Oliver Edelamnn
|
||||||
|
Author: Oliver Edelmann
|
||||||
|
|
||||||
|
Like Munin, this plugin is licensed under the GNU GPL v2 license
|
||||||
|
http://www.opensource.org/licenses/GPL-2.0
|
||||||
|
Like Munin, this plugin is licensed under the GNU GPL v2 license
|
||||||
|
http://www.opensource.org/licenses/GPL-2.0
|
||||||
|
This plugin requires the fritzconnection plugin. To install it using pip:
|
||||||
|
pip install fritzconnection
|
||||||
|
This plugin supports the following munin configuration parameters:
|
||||||
|
#%# family=auto contrib
|
||||||
|
#%# capabilities=autoconf
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||||
|
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
|
def print_values():
|
||||||
|
try:
|
||||||
|
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit("Couldn't get WAN traffic")
|
||||||
|
|
||||||
|
traffic = conn.transmission_rate
|
||||||
|
up = traffic[0]*8
|
||||||
|
down = traffic[1]*8
|
||||||
|
print('down.value %d' % down)
|
||||||
|
|
||||||
|
print('up.value %d' % up)
|
||||||
|
|
||||||
|
if not os.environ.get('traffic_remove_max') or "false" in os.environ.get('traffic_remove_max'):
|
||||||
|
max_traffic = conn.max_bit_rate
|
||||||
|
print('maxdown.value %d' % max_traffic[1])
|
||||||
|
|
||||||
|
print('maxup.value %d' % max_traffic[0])
|
||||||
|
|
||||||
|
|
||||||
|
def print_config():
|
||||||
|
try:
|
||||||
|
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit("Couldn't get WAN traffic")
|
||||||
|
|
||||||
|
max_traffic = conn.max_bit_rate
|
||||||
|
|
||||||
|
print("host_name %s" % hostname)
|
||||||
|
print("graph_title AVM Fritz!Box WAN traffic")
|
||||||
|
print("graph_args --base 1000")
|
||||||
|
print("graph_vlabel bit up per ${graph_period}")
|
||||||
|
print("graph_category network")
|
||||||
|
print("graph_order up maxup")
|
||||||
|
print("up.label bps")
|
||||||
|
print("up.type GAUGE")
|
||||||
|
print("up.draw AREA")
|
||||||
|
print("up.min 0")
|
||||||
|
print("up.max %d" % max_traffic[1])
|
||||||
|
print("up.warning %.0f" % (max_traffic[1]*0.6))
|
||||||
|
print("up.critical %.0f" % (max_traffic[1]*0.8))
|
||||||
|
print("up.info Traffic of the WAN interface.")
|
||||||
|
if not os.environ.get('traffic_remove_max') or "false" in os.environ.get('traffic_remove_max'):
|
||||||
|
print("maxup.label MAX")
|
||||||
|
print("maxup.type GAUGE")
|
||||||
|
print("maxup.draw LINE1")
|
||||||
|
print("maxup.info Maximum up speed of the WAN interface.")
|
||||||
|
if os.environ.get('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
|
||||||
|
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
||||||
|
try:
|
||||||
|
print_values()
|
||||||
|
except:
|
||||||
|
sys.exit("Couldn't retrieve fritzbox traffic")
|
4
fritzbox_uptime.py → fritzbox__uptime.py
Executable file → Normal file
4
fritzbox_uptime.py → fritzbox__uptime.py
Executable file → Normal file
@ -31,12 +31,13 @@ minutesLoc = {"de": "Minuten", "en": "minutes"}
|
|||||||
|
|
||||||
PAGE = 'energy'
|
PAGE = 'energy'
|
||||||
pattern = re.compile(patternLoc[locale])
|
pattern = re.compile(patternLoc[locale])
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
|
|
||||||
def get_uptime():
|
def get_uptime():
|
||||||
"""get the current uptime"""
|
"""get the current uptime"""
|
||||||
|
|
||||||
server = os.environ['fritzbox_ip']
|
server = hostname
|
||||||
password = os.environ['fritzbox_password']
|
password = os.environ['fritzbox_password']
|
||||||
|
|
||||||
session_id = fh.get_session_id(server, password)
|
session_id = fh.get_session_id(server, password)
|
||||||
@ -59,6 +60,7 @@ def get_uptime():
|
|||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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')
|
5
fritzbox_wifi_devices.py → fritzbox__wifi_devices.py
Executable file → Normal file
5
fritzbox_wifi_devices.py → fritzbox__wifi_devices.py
Executable file → Normal file
@ -25,13 +25,15 @@ import sys
|
|||||||
|
|
||||||
from fritzconnection.lib.fritzwlan import FritzWLAN
|
from fritzconnection.lib.fritzwlan import FritzWLAN
|
||||||
|
|
||||||
|
hostname = os.path.basename(__file__).split('_')[1]
|
||||||
|
|
||||||
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"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = FritzWLAN(address=os.environ['fritzbox_ip'], password=os.environ['fritzbox_password'])
|
conn = FritzWLAN(address=hostname, password=os.environ['fritzbox_password'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
sys.exit("Couldn't get connection uptime")
|
sys.exit("Couldn't get connection uptime")
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +42,7 @@ def get_connected_wifi_devices():
|
|||||||
|
|
||||||
|
|
||||||
def print_config():
|
def print_config():
|
||||||
|
print("host_name %s" % hostname)
|
||||||
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')
|
0
fritzbox_helper.py
Executable file → Normal file
0
fritzbox_helper.py
Executable file → Normal file
Loading…
Reference in New Issue
Block a user