Package: pi-hole-influx
Pi-hole-InfluxA simple daemonized script to report Pi-Hole stats to an InfluxDB, ready to be displayed via Grafana.Heads-up: the configuration options changed fundamentally in recent versions. Please read up on the current state below.Setup (Using Docker)To use docker for running the daemon, use the following command:dockerrun\-ePIHOLE_INFLUXDB_HOST="myhostname"\-ePIHOLE_INFLUXDB_PORT="8086"\-ePIHOLE_INFLUXDB_USERNAME="myusername"\-ePIHOLE_INFLUXDB_PASSWORD="mysupersecretpassword"\-ePIHOLE_INFLUXDB_DATABASE="pihole"\-ePIHOLE_INSTANCES="localhost=http://127.0.0.1/admin/api.php"\registry.gitlab.com/janw/pi-hole-influxFor running it on a Raspberry Pi (arm v7 arch), use the dedicatedarmv7image tag:dockerrun\-ePIHOLE_INFLUXDB_HOST="myhostname"\-ePIHOLE_INFLUXDB_USERNAME="myusername"\-ePIHOLE_INFLUXDB_PASSWORD="mysupersecretpassword"\--networkhost\registry.gitlab.com/janw/pi-hole-influx:armv7The following values are the defaults and will be used if not set:PIHOLE_INFLUXDB_PORT="8086"PIHOLE_INFLUXDB_HOST="127.0.0.1"PIHOLE_INFLUXDB_DATABASE="pihole"PIHOLE_INSTANCES="localhost=http://127.0.0.1/admin/api.php"PIHOLE_INSTANCEScontains the Pi-hole instances that are to be reported. Multiple instances can given in a dict-like boxed syntax, known asInline Tables in TOML:PIHOLE_INSTANCES="{first_one="http://127.0.0.1/admin/api.php",second_pihole="http://192.168.42.79/admin/api.php"[,…]}"Note that instances are prefixed by a custom name.Docker-compose exampleIf you want to run the daemon through Docker-compose, you might appreciate the configuration example below.version:"2"services:piholeinflux:image:registry.gitlab.com/janw/pi-hole-influxcontainer_name:piholeinfluxrestart:unless-stoppedenvironment:# Replace details with your InfluxDB's hostname and credentialsPIHOLE_INFLUXDB_HOST:"10.10.10.1"PIHOLE_INFLUXDB_PORT:"8086"PIHOLE_INFLUXDB_USERNAME:"pihole"PIHOLE_INFLUXDB_PASSWORD:"pihole"PIHOLE_INFLUXDB_DATABASE:"pihole"# Replace with your Pi-Hole's address including path to API belowPIHOLE_INSTANCES:"pihole=http://10.10.0.10/admin/api.php"# OPTIONAL: Instead of the aobove environment variables,#           use a custom copy of the user.toml config file.volumes:-./custom/config.toml:/user.tomlSetup (Traditional Way)As Pi-hole (as the name suggests) is built specifically with the Raspberry Pi in mind (and I run it on there as well), the following steps assume an instance of Pi-hole on Raspbian Strech Lite, with no additional modifications so far. Piholestatus will be configured to run on the same Pi.First install the necessary packages via apt as Raspbian Lite does have neither git nor pip installed.sudoaptupdate
sudoaptinstallgitpython3-pip-yNow clone the repo, install the Python dependencies, and make sure to copy and adjust the example configuation file to match your setup.# Install package via pippip3installpi-hole-influx# Download config.example and modify it (should be self-explanatory)wget-Ouser.tomlhttps://raw.githubusercontent.com/janw/pi-hole-influx/master/user.toml.example
viuser.tomlBefore starting the daemon for the first time, symlink the systemd service into place, reload, and enable the service.sudoln-s/home/pi/pi-hole-influx/piholeinflux.service/etc/systemd/system/
sudosystemctl--systemdaemon-reload
sudosystemctlenablepiholeinflux.serviceNow you're ready to start the daemon. Wait a few seconds to check its status.sudosystemctlstartpiholeinflux.service
sudosystemctlstatuspiholeinflux.serviceThe status should look as follows. Note theStatus:line showing the last time, the daemon reported to InfluxDB:● piholeinflux.service - Pi-hole-Influx - Send Pi-hole statistics to InfluxDB for visualization
   Loaded: loaded (/home/pi/pi-hole-influx/piholeinflux.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-06-22 19:03:56 UTC; 10min ago
     Docs: https://github.com/janw/pi-hole-influx
 Main PID: 21329 (python)
   Status: "Reported to InfluxDB at 2018-06-22 19:14:09 +0000"
   CGroup: /system.slice/piholeinflux.service
           └─21329 /usr/bin/python /home/pi/pi-hole-influx/piholeinflux.pySet up a Grafana DashboardThe example dashboard seenat the topuses the collected data and displays it in concise and sensible graphs and single stats. The dashboard can be imported into your Grafana instance from thedashboard.jsonfile included in the repo, or by using ID6603toimport it from Grafana's Dashboard Directory.AttributionsThe script originallycreated by Jon Hayward, adapted to work with InfluxDBby /u/tollsjo in December 2016, andimproved and extended by @johnappletree. "If I have seen further it is by standing on the shoulders of giants". 🤓