From af61f47dca77167e6bd89ffa8f52d3a5b0382adb Mon Sep 17 00:00:00 2001 From: Christoph Wempe Date: Thu, 2 Mar 2017 22:58:23 +0100 Subject: [PATCH] support dynamic hostnames --- fritzbox_connection_uptime.py | 5 ++++- fritzbox_cpu_temperature.py | 5 ++++- fritzbox_cpu_usage.py | 5 ++++- fritzbox_memory_usage.py | 5 ++++- fritzbox_power_consumption.py | 5 ++++- fritzbox_traffic.py | 5 ++++- fritzbox_uptime.py | 5 ++++- fritzbox_wifi_devices.py | 5 ++++- 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/fritzbox_connection_uptime.py b/fritzbox_connection_uptime.py index d9f6362..2f01474 100755 --- a/fritzbox_connection_uptime.py +++ b/fritzbox_connection_uptime.py @@ -19,6 +19,9 @@ import sys 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(): try: @@ -31,7 +34,7 @@ def print_values(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print "graph_title AVM Fritz!Box Connection Uptime" print "graph_args --base 1000 -l 0" print 'graph_vlabel uptime in days' diff --git a/fritzbox_cpu_temperature.py b/fritzbox_cpu_temperature.py index 159cc73..1dad21a 100755 --- a/fritzbox_cpu_temperature.py +++ b/fritzbox_cpu_temperature.py @@ -25,6 +25,9 @@ import fritzbox_helper as fh PAGE = '/system/ecostat.lua' 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(): """get the current cpu temperature""" @@ -42,7 +45,7 @@ def get_cpu_temperature(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print "graph_title AVM Fritz!Box CPU temperature" print "graph_vlabel degrees Celsius" print "graph_category sensors" diff --git a/fritzbox_cpu_usage.py b/fritzbox_cpu_usage.py index ef9469a..bbaef23 100755 --- a/fritzbox_cpu_usage.py +++ b/fritzbox_cpu_usage.py @@ -25,6 +25,9 @@ import fritzbox_helper as fh PAGE = '/system/ecostat.lua' 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(): """get the current cpu usage""" @@ -42,7 +45,7 @@ def get_cpu_usage(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print "graph_title AVM Fritz!Box CPU usage" print "graph_vlabel %" print "graph_category system" diff --git a/fritzbox_memory_usage.py b/fritzbox_memory_usage.py index 12ae9aa..b4f1f47 100755 --- a/fritzbox_memory_usage.py +++ b/fritzbox_memory_usage.py @@ -26,6 +26,9 @@ PAGE = '/system/ecostat.lua' pattern = re.compile('Query[1-3]\s="(\d{1,3})') 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(): """get the current memory usage""" @@ -44,7 +47,7 @@ def get_memory_usage(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print "graph_title AVM Fritz!Box Memory" print "graph_vlabel %" print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100" diff --git a/fritzbox_power_consumption.py b/fritzbox_power_consumption.py index 3a5cbc0..20f063f 100755 --- a/fritzbox_power_consumption.py +++ b/fritzbox_power_consumption.py @@ -26,6 +26,9 @@ PAGE = '/system/energy.lua' pattern = re.compile('(.+?)"bar\s(act|fillonly)"(.+?)\s(\d{1,3})\s%') 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(): """get the current power consumption usage""" @@ -44,7 +47,7 @@ def get_power_consumption(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print "graph_title AVM Fritz!Box Power Consumption" print "graph_vlabel %" print "graph_category network" diff --git a/fritzbox_traffic.py b/fritzbox_traffic.py index b1818cb..79d6c6b 100755 --- a/fritzbox_traffic.py +++ b/fritzbox_traffic.py @@ -19,6 +19,9 @@ import sys 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(): try: @@ -42,7 +45,7 @@ def print_values(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print "graph_title AVM Fritz!Box WAN traffic" print "graph_args --base 1000" print "graph_vlabel bits in (-) / out (+) per \${graph_period}" diff --git a/fritzbox_uptime.py b/fritzbox_uptime.py index 8910d68..43d0625 100755 --- a/fritzbox_uptime.py +++ b/fritzbox_uptime.py @@ -25,6 +25,9 @@ import fritzbox_helper as fh PAGE = '/system/energy.lua' 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(): """get the current uptime""" @@ -50,7 +53,7 @@ def get_uptime(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print "graph_title AVM Fritz!Box Uptime" print "graph_args --base 1000 -l 0" print 'graph_vlabel uptime in days' diff --git a/fritzbox_wifi_devices.py b/fritzbox_wifi_devices.py index 38e5565..eb8030f 100755 --- a/fritzbox_wifi_devices.py +++ b/fritzbox_wifi_devices.py @@ -25,6 +25,9 @@ import fritzbox_helper as fh PAGE = '/system/energy.lua' 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(): """gets the numbrer of currently connected wifi devices""" @@ -42,7 +45,7 @@ def get_connected_wifi_devices(): def print_config(): - print "host_name fritzbox" + print "host_name %s" % boxname print 'graph_title AVM Fritz!Box Connected Wifi Devices' print 'graph_vlabel Number of devices' print 'graph_args --base 1000'