2007-05-22 09:35:26 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Script to monitor PowerDNS performance
|
|
|
|
#
|
|
|
|
# Parameters understood:
|
|
|
|
#
|
|
|
|
# config (required)
|
|
|
|
# autoconf (optional - used by munin-config)
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
2017-09-28 09:54:22 +02:00
|
|
|
command="/usr/bin/pdns_control show"
|
2017-04-18 23:32:55 +02:00
|
|
|
state_file=$MUNIN_PLUGSTATE/pdns_rel.state
|
2007-05-22 09:35:26 +02:00
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2017-09-28 09:54:22 +02:00
|
|
|
if [ -e /usr/bin/pdns_control ]; then
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo no
|
|
|
|
exit 1
|
|
|
|
fi
|
2007-05-22 09:35:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo 'graph_title Power DNS Packet Cache Performance'
|
|
|
|
echo 'graph_args -l 0 --upper-limit 100 --base 1000'
|
|
|
|
echo 'graph_vlabel %'
|
2017-02-22 00:30:20 +01:00
|
|
|
echo 'graph_category dns'
|
2007-05-22 09:35:26 +02:00
|
|
|
echo 'graph_info This graph shows the Power DNS packet cache performance on the machine.'
|
|
|
|
echo 'packetcache_hitrate.label packet cache hitrate'
|
|
|
|
echo 'packetcache_hitrate.type GAUGE'
|
|
|
|
echo 'packetcache_hitrate.min 0'
|
|
|
|
echo 'packetcache_hitrate.max 100'
|
|
|
|
echo 'packetcache_hitrate.info Hits on the packets cache'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-09-28 09:54:22 +02:00
|
|
|
hits=$($command packetcache-hit)
|
|
|
|
queries=$($command udp-queries)
|
2017-09-29 09:27:34 +02:00
|
|
|
if [ -f "$state_file" ]; then
|
|
|
|
old_hits=$(head -n1 "$state_file")
|
|
|
|
old_queries=$(tail -n1 "$state_file")
|
2017-09-28 09:54:22 +02:00
|
|
|
fi
|
2007-05-22 09:35:26 +02:00
|
|
|
|
2017-09-29 09:27:34 +02:00
|
|
|
if [ -f "$state_file" ] && [ "$(stat --format=%Y "$state_file")" -gt "$(date --date="7 minutes ago" +%s)" ] ; then
|
|
|
|
d_hits=$((hits - old_hits))
|
|
|
|
d_queries=$((queries - old_queries))
|
2017-09-28 09:54:22 +02:00
|
|
|
if [ $d_queries -gt 0 ] ; then
|
2017-09-29 09:27:34 +02:00
|
|
|
echo packetcache_hitrate.value $(( d_hits * 100 / d_queries ))
|
2017-09-28 09:54:22 +02:00
|
|
|
fi
|
2007-05-22 09:35:26 +02:00
|
|
|
fi
|
|
|
|
|
2017-09-29 09:27:34 +02:00
|
|
|
echo "$hits" > "$state_file"
|
|
|
|
echo "$queries" >> "$state_file"
|