Skip to content

Commit

Permalink
Merge pull request #44 from pdreker/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pdreker authored Mar 31, 2021
2 parents e606fd9 + b6bd3c8 commit a148402
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
12 changes: 6 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ If there is any information missing or not displayed on your specific device, pl
## Known problems

* It seems like Fritz!OS does not internally count the packets for the Guest WiFi. So even though those counters are there they are always 0. This seems to be a problem with Fritz!OS and not the exporter. The counters are delivered nontheless, just in case this gets fixed by AVM.
* If you receive `Fatal Python error: init_interp_main: can't initialize time` when running the container you may have to update libseccomp on your Docker host. This issue mainly happens on Raspberry Pi and is triggered by a version of libseccomp2 which is too old. See <https://askubuntu.com/questions/1263284/apt-update-throws-signature-error-in-ubuntu-20-04-container-on-arm> (Method 2) and <https://github.com/pdreker/fritzbox_exporter/issues/38>

## Grafana Dashboard

Expand Down Expand Up @@ -110,7 +111,7 @@ Configuration is done via environment vars.

The main configuration is done inside the environment variable `FRITZ_EXPORTER_CONFIG`. This variable must contain the comma-separated address, username and password for the device. If you need multiple devices simply repeat the three values for the other devices.

An alternative it to use The three environment variables `FRITZ_HOSTNAME`, `FRITZ_USERNAME` and `FRITZ_PASSWORD`, This way you lose the ability to monitor multiple devices with one exporter but gain the ability To put `FRITZ_PASSWORD` into a kubernetes secret like shown in [Kubernetes deployment](#kubernetes-deployment).
An alternative is to use The three environment variables `FRITZ_HOSTNAME`, `FRITZ_USERNAME` and `FRITZ_PASSWORD`, This way you lose the ability to monitor multiple devices with one exporter but gain the ability To put `FRITZ_PASSWORD` into a kubernetes secret like shown in [Kubernetes deployment](#kubernetes-deployment).

Example for a single device (at 192.168.178.1 username monitoring and the password "mysupersecretpassword"):

Expand Down
24 changes: 12 additions & 12 deletions fritzexporter/fritzcapabilities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from abc import ABC, abstractclassmethod, abstractmethod

from fritzconnection.core.exceptions import ActionError, ServiceError
from fritzconnection.core.exceptions import ActionError, ServiceError, FritzInternalError
from prometheus_client.core import CounterMetricFamily, GaugeMetricFamily

logger = logging.getLogger(__name__)
Expand All @@ -28,7 +28,7 @@ def checkCapability(self, device):
for (svc, action) in self.requirements:
try:
device.fc.call_action(svc, action)
except (ServiceError, ActionError) as e:
except (ServiceError, ActionError, FritzInternalError) as e:
logger.warn(f'disabling metrics at service {svc}, action {action} - fritzconnection.call_action returned {e}')
self.present = False

Expand Down Expand Up @@ -67,7 +67,7 @@ def items(self):
def merge(self, other_caps):
for cap in self.capabilities:
self.capabilities[cap].present = self.capabilities[cap].present or other_caps.capabilities[cap].present

def empty(self):
return not any([ cap.present for cap in list(self.capabilities.values()) ])

Expand Down Expand Up @@ -100,7 +100,7 @@ def _getMetricValues(self, device):
num_hosts_result = device.fc.call_action('Hosts1', 'GetHostNumberOfEntries')
self.metrics['numhosts'].add_metric([device.serial], num_hosts_result['NewHostNumberOfEntries'])
yield self.metrics['numhosts']

#class HostInfo(FritzCapability):
# def __init__(self) -> None:
# super().__init__()
Expand All @@ -118,11 +118,11 @@ def _getMetricValues(self, device):
# for host_index in range(num_hosts_result['NewHostNumberOfEntries']):
# logger.debug(f'Fetching generic host information for host number {host_index}')
# host_result = device.fc.call_action('Hosts1', 'GetGenericHostEntry', NewIndex=host_index)
#
#
# host_ip = host_result['NewIPAddress']
# host_mac = host_result['NewMACAddress']
# host_name = host_result['NewHostName']
#
#
# if host_ip != "":
# logger.debug(f'Fetching extended AVM host information for host number {host_index} by IP {host_ip}')
# avm_host_result = device.fc.call_action('Hosts1', 'X_AVM-DE_GetSpecificHostEntryByIP', NewIPAddress=host_ip)
Expand Down Expand Up @@ -212,7 +212,7 @@ def createMetrics(self):
def _getMetricValues(self, device):
fritz_dslinfo_result = device.fc.call_action('WANDSLInterfaceConfig:1', 'GetInfo')
self.metrics['enable'].add_metric([device.serial], fritz_dslinfo_result['NewEnable'])

dslstatus = 1 if fritz_dslinfo_result['NewStatus'] == 'Up' else 0
self.metrics['status'].add_metric([device.serial], dslstatus)
self.metrics['datarate'].add_metric([device.serial, 'tx', 'curr'], fritz_dslinfo_result['NewUpstreamCurrRate'])
Expand All @@ -224,11 +224,11 @@ def _getMetricValues(self, device):
self.metrics['attenuation'].add_metric([device.serial, 'tx'], fritz_dslinfo_result['NewUpstreamAttenuation']/10)
self.metrics['attenuation'].add_metric([device.serial, 'rx'], fritz_dslinfo_result['NewDownstreamAttenuation']/10)

yield self.metrics['enable']
yield self.metrics['status']
yield self.metrics['datarate']
yield self.metrics['noisemargin']
yield self.metrics['attenuation']
yield self.metrics['enable']
yield self.metrics['status']
yield self.metrics['datarate']
yield self.metrics['noisemargin']
yield self.metrics['attenuation']

class WanPPPConnectionStatus(FritzCapability):
def __init__(self) -> None:
Expand Down

0 comments on commit a148402

Please sign in to comment.