Skip to content

Instantly share code, notes, and snippets.

@ivankristianto
Last active April 18, 2021 10:27
Show Gist options
  • Save ivankristianto/a3d8380d4612b5cf2ceaefe38fbc2812 to your computer and use it in GitHub Desktop.
Save ivankristianto/a3d8380d4612b5cf2ceaefe38fbc2812 to your computer and use it in GitHub Desktop.
PiHole Exporter as Background Service

Compile pihole-exporter

git clone https://github.com/eko/pihole-exporter.git  
cd pihole-exporter/  
GO111MODULE=on go mod vendor  
GOOS=linux GOARCH=arm GOARM=7 go build -o pihole_exporter .  
chmod +x pihole_exporter  

Create systemd unit

sudo vim /etc/systemd/system/pihole-exporter.service
[Unit]
Description=Run pihole-exporter so Promotheus can scrap the data.
After=network-online.target

[Service]
User=ivan
ExecStart=/home/ivan/Services/pihole-exporter/pihole_exporter -pihole_hostname 192.168.2.13 -pihole_password ivan_k20
RestartSec=5
Restart=always

[Install]
WantedBy=multi-user.target

Run it

sudo systemctl daemon-reload  
sudo systemctl enable pihole-exporter  
sudo systemctl start pihole-exporter  
sudo systemctl status pihole-exporter  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment