Install Pihole Node Exporter with this shell script
Change Pihole IP address and Password , then run.
nano install-node-exporter.sh
Copy and paste into the content, CTRL+X , Enter
#!/bin/bash
# Define variables
PIHOLE_IP="10.0.0.4" # Replace with your Pi-hole IP
PIHOLE_PASSWORD="xyz" # Replace with your Pi-hole password
SERVICE_FILE="/lib/systemd/system/pihole_exporter.service"
# Download the latest version of pihole-exporter
wget -c https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-amd64
# Create a directory for pihole-exporter
sudo mkdir -p /opt/pihole_exporter
# Add a user account to run the service
sudo useradd -r pihole_exporter
# Move the file to the new directory
sudo mv pihole_exporter-linux-amd64 /opt/pihole_exporter/
# Change the group permissions to the new pihole user
sudo chgrp pihole_exporter /opt/pihole_exporter
sudo chgrp pihole_exporter /opt/pihole_exporter/pihole_exporter-linux-amd64
# Make the binary executable
sudo chmod +x /opt/pihole_exporter/pihole_exporter-linux-amd64
# Create a service file for pihole-exporter
sudo bash -c "cat > $SERVICE_FILE <<EOF
[Unit]
Description=pihole_exporter
[Service]
ExecStart=/opt/pihole_exporter/pihole_exporter-linux-amd64 -pihole_hostname $PIHOLE_IP -pihole_password $PIHOLE_PASSWORD
WorkingDirectory=/opt/pihole_exporter
Restart=always
User=pihole_exporter
[Install]
WantedBy=multi-user.target
EOF"
# Reload the system daemon
sudo systemctl daemon-reload
# Start the service
sudo service pihole_exporter start
# Enable the service to run at startup
sudo systemctl enable pihole_exporter
# Restart
sudo shutdown -r now
No Comments