fritzcollectd
fritzcollectd copied to clipboard
Feedback
As I didn't see a better way, I'll try this way to give some feedback.
First of: Thanks for sharing this great project! Great stuff, and a beautiful Grafana dashboard!
I think the README could use some more hints to make things easier and avoid some irritation:
- add a note that you can set up a special user in the FritzBox for this task, and that it needs the permissions "FRITZ!Box Einstellungen" (so you don't have to use the main admin user).
- also it seems activating UPnP is not enough, but it also needs the check box "Zugriff für Anwendungen zulassen", right next to it
- add a note that it may take a while to see certain values in the Grafana dashboard, like Daily Traffic. It just shows "no data points" in the beginning (due to "GROUP BY time(1d)", maybe a bug in Grafana). This was a bit irritating me, as I thought I was still lacking some permission or setting in the FritzBox or whatever.
It would also be helpful to have clearer (error/warning) messages when some values cannot be retrieved from the FritzBox, because you miss one of the checkboxes in the FritzBox config. It wasn't always clear if the messages actually mean something or not.
- "collectd[1]: fritzcollectd: No password configured, some values cannot be queried" (also the README just says: "Some values require authentication and can only be queried if the router's Password has been configured.") ... but what values would that be? So then I could decide whether I want to give fritzcollectd access to the FritzBox or not.
- "collectd[1]: fritzcollectd: Skipping unsupported service action: LANEthernetInterfaceConfig:1 GetStatistics" ... what does this mean, what is the impact? is this a problem? And correct, I was actually missing one of the checkboxes. Not immediately clear from the message ;)
- "[2018-05-13 22:15:09] fritzcollectd: No readings received" for everything... also some checkbox missing.
Dashboard has a little glitch:
- The "Connection Status" and "DSL Link Status" can show "Connected" but at the same time be red when the box was disconnected for some time. Probably because mean() calculates something below 1, which confuses the color mapping. last() seems better.
I usually use telegraf to gather system metrics, so I needed to setup collectd just for fritzcollectd. I had no clue about collectd before. I wanted to put it into a container and connect it to my existing InfluxDB+Grafana setup. InfluxDB has support for getting data from collectd push via UDP. I had to do some digging through the internet for this. Here is a minimal docker file and config for this. As this might be a common use case, feel free to add it to the README.
I have everything in /opt/docker/collectd/
:
cd /opt/docker/collectd/
Dockerfile:
FROM debian:stretch-slim
# install collectd
RUN apt-get update -y && apt-get install --no-install-recommends -y \
collectd
# install fritzbox plugin
RUN apt-get install --no-install-recommends -y \
libpython2.7 \
python-setuptools \
python-wheel \
python-pip
RUN pip install fritzcollectd
CMD ["collectd", "-f"]
Build:
docker build -t collectd .
Minimal collectd.conf config for fritzcollectd:
FQDNLookup true
LoadPlugin logfile
<Plugin logfile>
LogLevel "info"
File STDOUT
Timestamp true
PrintSeverity false
</Plugin>
LoadPlugin network
LoadPlugin python
<Plugin network>
Server "influxdb" "25826"
</Plugin>
<Plugin python>
Import "fritzcollectd"
<Module fritzcollectd>
# Address "fritz.box"
# Port 49000
User "collectd"
Password "...."
Hostname "fritzbox"
# Instance "1"
# Verbose "True"
</Module>
</Plugin>
Run:
docker run -d --rm --name=collectd --net=influxnet --hostname=$HOSTNAME -v /opt/docker/collectd/collectd.conf:/etc/collectd/collectd.conf collectd
(--net=influxnet is where my InfluxDB listens)
Also the collectd types database is needed for InfluxDB:
get types.db
from collectd container:
docker cp collectd:/usr/share/collectd/types.db .
add mapping to influxdb container
"/opt/docker/collectd/types.db:/usr/share/collectd/types.db:ro"
InfluxDB config (mostly defaults):
[[collectd]]
enabled = true
bind-address = ":25826"
database = "collectd"
retention-policy = ""
batch-size = 5000
batch-pending = 10
batch-timeout = "10s"
read-buffer = 0
typesdb = "/usr/share/collectd/types.db"
security-level = "none"
auth-file = "/etc/collectd/auth_file"
parse-multivalue-plugin = "split"
Thanks
Michael
Hey there can you please post a screen shot of your router status dashboard? Mine is working but Total Downloads figure is less than Last 24 Hour download? Something is not right.
Yes, I was confused by this, too. I think this was caused by the Grafana queries, namely the grouping (maybe in combination with aggregation). This may or may not take some data into account depending on granularity. Esp. at the beginning of a time series this is noticeable and looks strange.
Thanks for your valuable feedback. I'll try to incorporate your ideas into the readme once I find the time.
Regarding your docker setup: Telegraf supports an exec plugin that can run a script and parse the output into InfluxDB. It might be easier to use fritzconnection directly in a script to retreive the values and convert the output to one of the various formats that InfluxDB supports. That way there's no need to use collectd just for the FritzBox.
@redm123 Thanks for the docker image.
But to get it working I have to login to the container and manually start the collectd process. :(
docker exec -it collectd-fritzbox /bin/bash
root@collectd-fritzbox:/# collectd -f
Any idea what is going wrong or how I can debug it?
Nevermind.
I just saw you added collectd
at the end of your docker run
command.
I just changed my Dockerbuild
to use CMD collectd -f
at the end.
It now works for me. 😃
Yes, there is a CMD
at the end of the Dockerfile, that's important ;) The collectd
at the end of docker run
just refers to the image to start. The command would need to be specified after that, like: docker run ... collectd collectd -f
. So without that or CMD docker run wouldn't start anything (or maybe just /bin/sh or whatever default, not sure). For debugging docker inspect ...
and docker logs ...
are quite helpful, also docker ps
shows the COMMAND that was run.
Anyway, glad it works for you now :)
Thanks for your valuable feedback. I'll try to incorporate your ideas into the readme once I find the time.
Readme is clearer now, Thanks 👍
Regarding your docker setup: Telegraf supports an exec plugin that can run a script and parse the output into InfluxDB. It might be easier to use fritzconnection directly in a script to retreive the values and convert the output to one of the various formats that InfluxDB supports. That way there's no need to use collectd just for the FritzBox.
Well, you're right, didn't think about that. On the other hand the Telegraf is about the only thing I run right on the system to gather system metrics, so I'd like to keep it as lean as possible. (Yes, you can also run it in a container and make system interfaces accessible, but it becomes somewhat pointless then and yet some things are still not accessible.) The fritzbox stuff doesn't need system access, so stuffing it into a slim container is actually quite nice and clean. And then it doesn't really matter anymore that it uses collectd. And once you have a Docker recipe ready to use, it's probably a lot easier than fiddling with the raw fritzconnection script to wire it to Telegraf manually 😉