hostname fixed

This commit is contained in:
oe73773 2020-07-11 18:00:44 +02:00
parent aa12d83859
commit 5c48631405
9 changed files with 23 additions and 20 deletions

View File

@ -74,7 +74,7 @@ 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
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)

View File

@ -24,10 +24,11 @@ import sys
from fritzconnection.lib.fritzstatus import FritzStatus
hostname = os.path.basename(__file__).split('_')[1]
def print_values():
try:
conn = FritzStatus(address=os.environ['fritzbox_ip'], password=os.environ['fritzbox_password'])
conn = FritzStatus(address=hostname, password=os.environ['fritzbox_password'])
except Exception:
sys.exit("Couldn't get connection uptime")
@ -36,7 +37,6 @@ def print_values():
def print_config():
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print("graph_title AVM Fritz!Box Connection Uptime")
print("graph_args --base 1000 -l 0")

View File

@ -21,12 +21,13 @@ import sys
import fritzbox_helper as fh
PAGE = 'ecoStat'
hostname = os.path.basename(__file__).split('_')[1]
def get_cpu_temperature():
"""get the current cpu temperature"""
server = os.environ['fritzbox_ip']
server = hostname
password = os.environ['fritzbox_password']
session_id = fh.get_session_id(server, password)
@ -36,7 +37,6 @@ def get_cpu_temperature():
def print_config():
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print("graph_title AVM Fritz!Box CPU temperature")
print("graph_vlabel degrees Celsius")

View File

@ -20,13 +20,14 @@ import os
import sys
import fritzbox_helper as fh
PAGE = { '7': 'ecoStat', '6': 'system/ecostat.lua' }
PAGE = 'ecoStat'
hostname = os.path.basename(__file__).split('_')[1]
def get_cpu_usage():
"""get the current cpu usage"""
server = os.environ['fritzbox_ip']
server = hostname
password = os.environ['fritzbox_password']
session_id = fh.get_session_id(server, password)
@ -36,7 +37,6 @@ def get_cpu_usage():
def print_config():
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print("graph_title AVM Fritz!Box CPU usage")
print("graph_vlabel %")

View File

@ -22,12 +22,13 @@ import fritzbox_helper as fh
PAGE = 'ecoStat'
USAGE = ['strict', 'cache', 'free']
hostname = os.path.basename(__file__).split('_')[1]
def get_memory_usage():
"""get the current memory usage"""
server = os.environ['fritzbox_ip']
server = hostname
password = os.environ['fritzbox_password']
session_id = fh.get_session_id(server, password)
@ -38,7 +39,6 @@ def get_memory_usage():
def print_config():
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print("graph_title AVM Fritz!Box Memory")
print("graph_vlabel %")

View File

@ -24,12 +24,12 @@ import fritzbox_helper as fh
PAGE = 'energy'
DEVICES = ['system', 'cpu', 'wifi', 'dsl', 'ab', 'usb']
hostname = os.path.basename(__file__).split('_')[1]
def get_power_consumption():
"""get the current power consumption usage"""
server = os.environ['fritzbox_ip']
server = hostname
password = os.environ['fritzbox_password']
session_id = fh.get_session_id(server, password)
@ -41,7 +41,6 @@ def get_power_consumption():
def print_config():
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print("graph_title AVM Fritz!Box Power Consumption")
print("graph_vlabel %")

View File

@ -24,10 +24,13 @@ import sys
from fritzconnection.lib.fritzstatus import FritzStatus
hostname = os.path.basename(__file__).split('_')[1]
def print_values():
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:
print(e)
sys.exit("Couldn't get WAN traffic")
traffic = conn.transmission_rate
@ -46,13 +49,13 @@ def print_values():
def print_config():
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:
print(e)
sys.exit("Couldn't get WAN traffic")
max_traffic = conn.max_bit_rate
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print("graph_title AVM Fritz!Box WAN traffic")
print("graph_args --base 1000")

View File

@ -31,12 +31,13 @@ minutesLoc = {"de": "Minuten", "en": "minutes"}
PAGE = 'energy'
pattern = re.compile(patternLoc[locale])
hostname = os.path.basename(__file__).split('_')[1]
def get_uptime():
"""get the current uptime"""
server = os.environ['fritzbox_ip']
server = hostname
password = os.environ['fritzbox_password']
session_id = fh.get_session_id(server, password)
@ -59,7 +60,6 @@ def get_uptime():
def print_config():
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print("graph_title AVM Fritz!Box Uptime")
print("graph_args --base 1000 -l 0")

View File

@ -25,13 +25,15 @@ import sys
from fritzconnection.lib.fritzwlan import FritzWLAN
hostname = os.path.basename(__file__).split('_')[1]
def get_connected_wifi_devices():
"""gets the numbrer of currently connected wifi devices"""
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:
print(e)
sys.exit("Couldn't get connection uptime")
@ -40,7 +42,6 @@ def get_connected_wifi_devices():
def print_config():
hostname = os.path.basename(__file__).split('_')[1]
print("host_name %s" % hostname)
print('graph_title AVM Fritz!Box Connected Wifi Devices')
print('graph_vlabel Number of devices')