Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / network / dns / pdns_rel @ a2f35e9b

Historique | Voir | Annoter | Télécharger (1,48 ko)

1 8e14a913 Jan Behrend
#!/bin/bash
2
#
3
# Script to monitor PowerDNS performance
4
#
5
# Parameters understood:
6
#
7
#       config   (required)
8
#       autoconf (optional - used by munin-config)
9
#%# family=auto
10
#%# capabilities=autoconf
11
12
command="/etc/init.d/pdns show"
13
state_file=/var/lib/munin/plugin-state/pdns_rel.state
14
15
if [ "$1" = "autoconf" ]; then
16
        echo yes
17
        exit 0
18
fi
19
20
if [ "$1" = "config" ]; then
21
        echo 'graph_title Power DNS Packet Cache Performance'
22
        echo 'graph_args -l 0 --upper-limit 100 --base 1000'
23
        echo 'graph_vlabel %'
24
        echo 'graph_category Power DNS'
25
        echo 'graph_info This graph shows the Power DNS packet cache performance on the machine.'
26
        echo 'packetcache_hitrate.label packet cache hitrate'
27
        echo 'packetcache_hitrate.type GAUGE'
28
        echo 'packetcache_hitrate.min 0'
29
        echo 'packetcache_hitrate.max 100'
30
        echo 'packetcache_hitrate.info Hits on the packets cache'
31
        exit 0
32
fi
33
34
hits=$($command packetcache-hit | awk -F= '{print $2}')
35
queries=$($command udp-queries | awk -F= '{print $2}')
36
old_hits=$(cat $state_file | head -n1)
37
old_queries=$(cat $state_file | tail -n1)
38
39
if [ -f $state_file ] && [ $(ls -l --time-style=+%s $state_file | awk '{print $6}') -gt $(date --date="7 minutes ago" +%s) ] ; then
40
	d_hits=$(($hits - $old_hits))
41
	d_queries=$(($queries - $old_queries))
42
	if [ $d_queries -gt 0 ] ; then
43
	   echo packetcache_hitrate.value $(( $d_hits * 100 / $d_queries ))
44
	fi
45
fi
46
47
echo $hits > $state_file
48
echo $queries >> $state_file