Projet

Général

Profil

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

root / plugins / bind / bind9_socket_stats @ c81c20ab

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

1
#!/bin/bash
2
#
3
# Plugin to monitor Bind9 Name Server Socket Stats
4
#
5
# Author:
6
#    Dave Fennell <dave@microtux.co.uk>
7
#
8
# Created:
9
#    20th December 2012
10
#
11
# License:
12
#    GPLv2
13
#
14
# Usage:
15
#    Place in /etc/munin/plugins/ (or link it there using ln -s)
16
#
17

    
18
# change those to reflect your bind configuration (use plugin configuration)
19
# stat file
20
if [ "$stat_file" = "" ]; then
21
	stat_file="/var/cache/bind/named.stats"
22
fi
23

    
24
# rndc path
25
if [ "$rndc" = "" ]; then
26
	rndc="/usr/sbin/rndc"
27
fi
28

    
29
# Blank the stats file (else stats are appended not replaced)
30
rm ${stat_file}
31

    
32
# Ask to bind to build new one
33
${rndc} stats
34

    
35
# The section we are looking for in the stats.
36
section="Socket I/O Statistics"
37

    
38
# Get all the lines in the section:
39
# - cat the file
40
# - use sed to get lines after (and excluding) the section start tag
41
# - use sed to get lines up to (and excluding) the next section start tag
42
# - use grep to remove any lines starting with a [
43
cmd='cat "/var/cache/bind/named.stats" | sed "0,/^\+\+ '${section//\//\\/}' \+\+/d" | sed -e "/^\+\+/,\$d" | grep -v "^\["'
44

    
45
# Config mode.
46
if [ "$1" = "config" ]; then
47
	echo 'graph_args --lower-limit 0'
48
	echo 'graph_category dns'
49
	echo 'graph_info '${section}' for the Bind9 Name Server'
50
	echo 'graph_scale no'
51
	echo 'graph_title Bind9 '${section}
52
	echo 'graph_vlabel requests/${graph_period}'
53

    
54
	# Output the stat configs.
55
	eval ${cmd} | while read num name
56
	do
57
		label=${name}
58

    
59
		# All lowercase.
60
		key=$(echo "$name" | tr 'A-Z' 'a-z')
61

    
62
		# Now change names to all have no spaces.
63
		key=${key//[\/ - ]/_}
64

    
65
		echo ${key}.label ${label}
66
		echo ${key}.info ${name}
67
		echo ${key}.type COUNTER
68
	done
69

    
70
	# If dirty config capability is enabled then fall through
71
	# to output the data with the config information.
72
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
73
fi
74

    
75
# Output the stats.
76
eval ${cmd} | while read num name
77
do
78
	# All lowercase.
79
	key=$(echo "$name" | tr 'A-Z' 'a-z')
80

    
81
	# Now change names to all have no spaces.
82
	key=${key//[\/ - ]/_}
83

    
84
	echo ${key}.value ${num}
85
done