fritzbox_exporter icon indicating copy to clipboard operation
fritzbox_exporter copied to clipboard

Idea: Allow to scrape multiple fritzboxes

Open bachp opened this issue 8 years ago • 3 comments

Currently the exporter can connect to exactly one fritzbox. So in order so monitor multiple devices multiple exporters need to be setup. And a new port assigned to each.

Other exporters that pull in metrics from other sources like the snmp_exporter or the blackbox_exporter allow to fetch from multiple sources at once.

I propose to extend the exporter to support multiple devices with a single process. Most probaly the best way would be through a config file specifying which fritz boxes to scrape or torough paramters sent from prometheus like it is done for blackbox_exporter. So something like: http://localhost:9133/probe?address=fritz.box&port=49000.

Does this feature make sense or does it just over complicate stuff?

bachp avatar Mar 08 '17 16:03 bachp

I have no strong opinion either way. I think it is pretty unusual to have more than one fritzbox because its primary purpose is as a home DSL gateway. In the odd case it is easy to start more than one instance.

It would be very simple to support more than one fritzbox in a single process. The most difficult part would be the configuration. I would tend to use the command line, because it is very simple. Even node_exporter does not use a config file.

I dislike giving the address in the query parameter from prometheus. This allows anyone who can query the service to have the server connect to any other system and do stuff there. With a fixed configuration no harm can be done other than querying a fixed set of metrics.

I will gladly accept a pull request ;-)

ndecker avatar Mar 08 '17 18:03 ndecker

The case I have at hand is that I have two fritz boxes connected via VPN and I would like to monitor both. But I guess you are right it's not the common case and running two instances is not too hard either.

I will give it a try and see if it can be done without adding to much complexity.

bachp avatar Mar 08 '17 19:03 bachp

OK. Have a look at https://github.com/xperimental/fritzbox_exporter The first few commit until 36b9f99 refactor the exporter into a seperate package with a prometheus.Collector interface.

In main you just need to call collector.New and prometheus.MustRegister for each box.

One thing: Currently MustRegister will panic because the metric fritzbox_exporter_collect_errors ( https://github.com/xperimental/fritzbox_exporter/blob/smart-home/collector/collector.go#L151 ) is redefined for each collector. It should be a package scoped CounterVec.

ndecker avatar Mar 08 '17 23:03 ndecker

Im closing this. It would be pretty easy to start multiple collectors from main. But the commandline / environment variable interface would get pretty complex if different configuration would apply to multiple boxes.

ndecker avatar Dec 12 '22 22:12 ndecker