Không có mô tả

subDesTagesMitExtraKaese 10fee1d6e6 pin pypi package versions 1 năm trước cách đây
.github 8ef797b8b0 Merge branch 'main' of github.com:chriscn/pihole-to-influxdb 2 năm trước cách đây
.dockerignore 2e1b58a0b3 add a reference dashboard 2 năm trước cách đây
.gitignore 1135eb891a Initial commit 3 năm trước cách đây
Dockerfile 60e3adc8ab update debian release 1 năm trước cách đây
Pi-hole-grafana-dashboard.json 2e1b58a0b3 add a reference dashboard 2 năm trước cách đây
README.md 1d599c0eb5 api.php endpoint now requires token auth 1 năm trước cách đây
main.py f81a93ede1 fix app_mode setting 2 năm trước cách đây
pihole.py 1d599c0eb5 api.php endpoint now requires token auth 1 năm trước cách đây
requirements.txt 10fee1d6e6 pin pypi package versions 1 năm trước cách đây

README.md

pihole-to-influxdb

Introduction

Based slightly on my other project, speedtest-to-influxdb. This project leverages the Pi-Hole API to gather data about your PiHole instance and store it inside of InfluxDB for your future projects. An example dashoard can be found here.

This project is automatically built through GitHub actions and published to DockerHub.

Setup

Configuring the script

The InfluxDB connection settings can be configured as followed:

  • INFLUX_DB_URL=http://192.168.xxx.xxx:8086
  • INFLUX_DB_ORG=<your org name>
  • INFLUX_DB_TOKEN=<token>
  • INFLUX_DB_BUCKET=pihole

The PiHole settings can be configured as followed:

  • PIHOLE_URL=http://192.168.xxx.xxx
  • PIHOLE_INTERVAL=15 Interval in seconds

Optionally you can also configure the following:

  • PIHOLE_AUTHENTICATION=<token>
  • LOG_LEVEL=DEBUG
  • APP_MODE=Totals

Authentication

The Pi-Hole API requires you to be authenticated. This can be achieved by supplying the PIHOLE_AUTHENTICATION environment variable with the token from the API settings page of the admin interface.

Sidenote

This does mean that your token is stored in plaintext as an environment variable and as such as malicious actor could find it and access your PiHole instance. You are advised to use this at your own risk.

App Modes

The APP_MODE changes the way the script works.

There are three modes available to choose from:

  • APP_MODE=Totals This is the default mode
  • APP_MODE=Live
  • APP_MODE=Raw

The default mode is Totals which will only send the daily totals of the PiHole instance, as displayed in the GUI. Another mode is Live which will send a summary of the Pi-hole queries of the last PIHOLE_INTERVAL seconds. The last mode is Raw which will send the raw data of the Pi-hole queries.

Docker Command

docker run -d --name pihole-to-influx \
  -e 'INFLUX_DB_URL'='<influxdb url>' \
  -e 'INFLUX_DB_ORG'='<influxdb org>' \
  -e 'INFLUX_DB_TOKEN'='<influxdb token>' \
  -e 'INFLUX_DB_BUCKET'='pihole' \
  -e 'PIHOLE_INTERVAL'='1800' \
  -e 'PIHOLE_URL'='192.168.xxx.xxx'  \
  chriscn/pihole-to-influxdb

docker-compose

version: '3'
services:
  pihole-to-influxdb:
    image: chriscn/pihole-to-influxdb
    container_name: pihole-to-influxdb
    environment:
    - "INFLUX_DB_URL=http://192.168.xxx.xxx:8086"
    - "INFLUX_DB_ORG=myOrg"
    - "INFLUX_DB_TOKEN=<token>"
    - "INFLUX_DB_BUCKET=pihole"
    - "PIHOLE_URL=http://192.168.xxx.xxx"
    - "PIHOLE_INTERVAL=15"
    - "PIHOLE_AUTHENTICATION=<token>"
    - "LOG_LEVEL=DEBUG"
    - "APP_MODE=Totals"