2021-10-01 18:18:40 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Sample setup for '/etc/munin/plugin-conf.d/munin-node':
|
|
|
|
#
|
|
|
|
# [pihole_*]
|
|
|
|
# user root
|
|
|
|
# env.host 127.0.0.1
|
|
|
|
# env.port 80
|
|
|
|
# env.api /admin/api.php
|
|
|
|
|
|
|
|
envhost=${host:-127.0.0.1}
|
|
|
|
envport=${port:-80}
|
|
|
|
envapi=${api:-/admin/api.php}
|
|
|
|
|
|
|
|
apicall=$(curl -s "$envhost:$envport$envapi" 2>/dev/null)
|
|
|
|
stats=$(echo $apicall | sed 's/[{}"]//g' | tr "," "\n")
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
config)
|
|
|
|
echo "graph_title Pihole Blocked Domains"
|
|
|
|
echo "graph_vlabel count"
|
|
|
|
echo "graph_category pihole"
|
|
|
|
echo "graph_info This graph shows the Pihole unique blocked domains."
|
|
|
|
|
|
|
|
for stat in $stats
|
|
|
|
do
|
|
|
|
uid=$(echo $stat | sed 's/:.*//')
|
|
|
|
if [ $uid = "domains_being_blocked" ]; then
|
2021-10-01 18:21:51 +02:00
|
|
|
echo "$uid.label blocked domains"
|
2021-10-01 18:29:38 +02:00
|
|
|
echo "$uid.draw AREA"
|
2021-10-01 18:18:40 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
for stat in $stats
|
|
|
|
do
|
|
|
|
uid=$(echo $stat | sed 's/:.*//')
|
|
|
|
if [ $uid = "domains_being_blocked" ]; then
|
|
|
|
value=$(echo $stat | sed 's/.*://')
|
|
|
|
echo "$uid.value $value"
|
|
|
|
fi
|
|
|
|
done
|