From 8b63414d20aafc50d7b5804a2370859f4d8482d9 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Mon, 30 Sep 2019 14:24:34 +1000 Subject: [PATCH] Remove 'AVM Fritz!Box' from titles when env.host_name is specified This allows the graph to be better grouped with other hosts. Signed-off-by: Olivier Mehani --- fritzbox_connection_uptime.py | 6 ++++-- fritzbox_cpu_temperature.py | 8 +++++--- fritzbox_cpu_usage.py | 8 +++++--- fritzbox_memory_usage.py | 8 +++++--- fritzbox_power_consumption.py | 10 ++++++---- fritzbox_traffic.py | 8 +++++--- fritzbox_uptime.py | 8 +++++--- fritzbox_wifi_devices.py | 10 ++++++---- 8 files changed, 41 insertions(+), 25 deletions(-) diff --git a/fritzbox_connection_uptime.py b/fritzbox_connection_uptime.py index 40af873..c80f145 100755 --- a/fritzbox_connection_uptime.py +++ b/fritzbox_connection_uptime.py @@ -31,6 +31,10 @@ def print_values(): def print_config(): + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print("graph_title Connection Uptime") + else: print("graph_title AVM Fritz!Box Connection Uptime") print("graph_args --base 1000 -l 0") print('graph_vlabel uptime in days') @@ -38,8 +42,6 @@ def print_config(): print("graph_category network") print("uptime.label uptime") print("uptime.draw AREA") - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == "__main__": diff --git a/fritzbox_cpu_temperature.py b/fritzbox_cpu_temperature.py index 770d4d1..0c42fcb 100755 --- a/fritzbox_cpu_temperature.py +++ b/fritzbox_cpu_temperature.py @@ -41,7 +41,11 @@ def get_cpu_temperature(): def print_config(): - print("graph_title AVM Fritz!Box CPU temperature") + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print("graph_title Temperatures") + else: + print("graph_title AVM Fritz!Box CPU temperature") print("graph_vlabel degrees Celsius") print("graph_category sensors") print("graph_order tmp") @@ -51,8 +55,6 @@ def print_config(): print("temp.graph LINE1") print("temp.min 0") print("temp.info Fritzbox CPU temperature") - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == '__main__': diff --git a/fritzbox_cpu_usage.py b/fritzbox_cpu_usage.py index 7797b9d..c331c75 100755 --- a/fritzbox_cpu_usage.py +++ b/fritzbox_cpu_usage.py @@ -41,7 +41,11 @@ def get_cpu_usage(): def print_config(): - print("graph_title AVM Fritz!Box CPU usage") + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print("graph_title CPU usage") + else : + print("graph_title AVM Fritz!Box CPU usage") print("graph_vlabel %") print("graph_category system") print("graph_order cpu") @@ -51,8 +55,6 @@ def print_config(): print("cpu.graph AREA") print("cpu.min 0") print("cpu.info Fritzbox CPU usage") - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == '__main__': diff --git a/fritzbox_memory_usage.py b/fritzbox_memory_usage.py index 513d03d..7cba90c 100755 --- a/fritzbox_memory_usage.py +++ b/fritzbox_memory_usage.py @@ -43,7 +43,11 @@ def get_memory_usage(): def print_config(): - print("graph_title AVM Fritz!Box Memory") + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print("graph_title Memory in percent") + else: + print("graph_title AVM Fritz!Box Memory") print("graph_vlabel %") print("graph_args --base 1000 -r --lower-limit 0 --upper-limit 100") print("graph_category system") @@ -59,8 +63,6 @@ def print_config(): print("free.label free") print("free.type GAUGE") print("free.draw STACK") - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == '__main__': diff --git a/fritzbox_power_consumption.py b/fritzbox_power_consumption.py index ee18c3d..8f0e660 100755 --- a/fritzbox_power_consumption.py +++ b/fritzbox_power_consumption.py @@ -46,9 +46,13 @@ def get_power_consumption(): def print_config(): - print("graph_title AVM Fritz!Box Power Consumption") + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print("graph_title Power consumption") + else: + print("graph_title AVM Fritz!Box Power Consumption") print("graph_vlabel %") - print("graph_category system") + print("graph_category sensors") print("graph_order system cpu wifi dsl ab usb") print("system.label system") print("system.type GAUGE") @@ -86,8 +90,6 @@ def print_config(): print("usb.min 0") print("usb.max 100") print("usb.info Fritzbox usb devices power consumption") - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == '__main__': diff --git a/fritzbox_traffic.py b/fritzbox_traffic.py index 14c2320..9636be0 100755 --- a/fritzbox_traffic.py +++ b/fritzbox_traffic.py @@ -43,7 +43,11 @@ def print_values(): def print_config(): - print("graph_title AVM Fritz!Box WAN traffic") + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print("graph_title Uplink traffic") + else: + print("graph_title AVM Fritz!Box WAN traffic") print("graph_args --base 1000") print("graph_vlabel bits in (-) / out (+) per \${graph_period}") print("graph_category network") @@ -71,8 +75,6 @@ def print_config(): print("maxup.negative maxdown") print("maxup.draw LINE1") print("maxup.info Maximum speed of the WAN interface.") - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == "__main__": diff --git a/fritzbox_uptime.py b/fritzbox_uptime.py index 384c8e6..bb04621 100755 --- a/fritzbox_uptime.py +++ b/fritzbox_uptime.py @@ -64,15 +64,17 @@ def get_uptime(): def print_config(): - print("graph_title AVM Fritz!Box Uptime") + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print("graph_title Uptime") + else: + print("graph_title AVM Fritz!Box Uptime") print("graph_args --base 1000 -l 0") print('graph_vlabel uptime in days') print("graph_scale no'") print("graph_category system") print("uptime.label uptime") print("uptime.draw AREA") - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == '__main__': diff --git a/fritzbox_wifi_devices.py b/fritzbox_wifi_devices.py index 0c1ff47..e8ecdd5 100755 --- a/fritzbox_wifi_devices.py +++ b/fritzbox_wifi_devices.py @@ -32,7 +32,7 @@ def get_connected_wifi_devices(): - """gets the numbrer of currently connected wifi devices""" + """gets the numbrer of currently connected wi-fi devices""" server = os.getenv('fritzbox_ip') password = os.getenv('FRITZ_PASSWORD') @@ -51,7 +51,11 @@ def get_connected_wifi_devices(): def print_config(): - print('graph_title AVM Fritz!Box Connected Wifi Devices') + if os.environ.get('host_name'): + print("host_name " + os.getenv('host_name')) + print('graph_title Connected Wi-FiDevices') + else: + print('graph_title AVM Fritz!Box Connected Wi-Fi Devices') print('graph_vlabel Number of devices') print('graph_args --base 1000') print('graph_category network') @@ -60,8 +64,6 @@ def print_config(): print('wifi.type GAUGE') print('wifi.graph LINE1') print('wifi.info Wifi Connections on 2.4 & 5 Ghz') - if os.environ.get('host_name'): - print("host_name " + os.getenv('host_name')) if __name__ == '__main__':