pihole: % ads

This commit is contained in:
Michael Grote 2021-10-01 18:27:50 +02:00
parent 82f143380e
commit e17311744a

43
extern/pihole/pihole_ads_percentage vendored Normal file
View file

@ -0,0 +1,43 @@
#!/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 today ads"
echo "graph_vlabel %"
echo "graph_category pihole"
echo "graph_info This graph shows the Pihole percentage of todays ads."
for stat in $stats
do
uid=$(echo $stat | sed 's/:.*//')
if [ $uid = "ads_percentage_today" ]; then
echo "$uid.label today ads %"
fi
done
exit 0;;
esac
for stat in $stats
do
uid=$(echo $stat | sed 's/:.*//')
if [ $uid = "ads_percentage_today" ]; then
value=$(echo $stat | sed 's/.*://')
echo "$uid.value $value"
fi
done