From c1b1d4bffa570aedde1fad7b726ee5c8a5a327eb Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Wed, 6 Sep 2017 21:35:23 +0200 Subject: [PATCH] Fixes #13. Configurable traffic maximum --- README.md | 4 ++++ fritzbox_traffic.py | 30 ++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 98e4337..b04082f 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ If you are using the scripts on a different Fritz!Box model please let me know b fritzbox\_traffic shows you the traffic of the WAN interface (requires fritzconnection) ![http://i.imgur.com/8BwNMOL.png](http://i.imgur.com/8BwNMOL.png) + + If you do not want to show the interface maximum values, add the following to your plugin-configuration: + + env.traffic_remove_max true ## fritzbox\_connection\_uptime diff --git a/fritzbox_traffic.py b/fritzbox_traffic.py index 256d4be..efecb2f 100755 --- a/fritzbox_traffic.py +++ b/fritzbox_traffic.py @@ -32,13 +32,14 @@ def print_values(): up_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetTotalBytesSent')['NewTotalBytesSent'] print ('up.value %d' % up_traffic) - max_down_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')[ - 'NewLayer1DownstreamMaxBitRate'] - print ('maxdown.value %d' % max_down_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) - max_up_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')[ - 'NewLayer1UpstreamMaxBitRate'] - print ('maxup.value %d' % max_up_traffic) + max_up_traffic = conn.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')[ + 'NewLayer1UpstreamMaxBitRate'] + print ('maxup.value %d' % max_up_traffic) def print_config(): @@ -61,14 +62,15 @@ def print_config(): print "up.max 1000000000" print "up.negative down" print "up.info Traffic 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 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." if __name__ == "__main__":