mirror of
https://github.com/Tafkas/fritzbox-munin.git
synced 2023-10-10 11:36:55 +00:00
Merge 0912a230dd61f63f46a31e427ea1149054e67d8b into c82e99a4b4df531138bc0f373993487d82e430bb
This commit is contained in:
commit
c705eec080
@ -20,11 +20,33 @@ import sys
|
|||||||
from fritzconnection import FritzConnection
|
from fritzconnection import FritzConnection
|
||||||
|
|
||||||
|
|
||||||
|
def model_needs_login(model):
|
||||||
|
"""
|
||||||
|
Checks if provided fritzbox model is in the list of devices which need an authenticated login
|
||||||
|
to extract traffic data.
|
||||||
|
|
||||||
|
:param model: String describing the fritzbox model; as returned from FritzConnection().modelname
|
||||||
|
:return bool
|
||||||
|
"""
|
||||||
|
models_require_login = [
|
||||||
|
"FRITZ!Box 6490 Cable",
|
||||||
|
]
|
||||||
|
for m in models_require_login:
|
||||||
|
if model.startswith(m):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def print_values():
|
def print_values():
|
||||||
try:
|
try:
|
||||||
conn = FritzConnection(address=os.environ['fritzbox_ip'])
|
conn = FritzConnection(address=os.environ['fritzbox_ip'])
|
||||||
|
if model_needs_login(conn.modelname):
|
||||||
|
conn = FritzConnection(address=os.environ['fritzbox_ip'],
|
||||||
|
user='dslf-config',
|
||||||
|
password=os.environ['fritzbox_password'],
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.exit("Couldn't get WAN traffic")
|
sys.exit("Couldn't establish connection to fritzbox")
|
||||||
|
|
||||||
down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesReceived')['NewTotalBytesReceived']
|
down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesReceived')['NewTotalBytesReceived']
|
||||||
print('down.value %d' % down_traffic)
|
print('down.value %d' % down_traffic)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user