~ubuntu-branches/ubuntu/gutsy/munin/gutsy

« back to all changes in this revision

Viewing changes to node/node.d/named.in

  • Committer: Bazaar Package Importer
  • Author(s): Tore Anderson
  • Date: 2004-05-21 20:51:19 UTC
  • Revision ID: james.westby@ubuntu.com-20040521205119-oz8bllbjp9hs80ig
Tags: upstream-0+1.0.0pre5
ImportĀ upstreamĀ versionĀ 0+1.0.0pre5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Munin plugin for named.  This is a bit experimental, we will have to see
 
4
# which statistics prove to have any meaning to get a feel with what happens
 
5
# on the nameserver.
 
6
#
 
7
# Nicolai Langfeldt (janl@linpro.no) 27.8.2003
 
8
 
9
# Enviroment variables:
 
10
#
 
11
#       logfile   - set which log file to use
 
12
 
13
# $Log: named.in,v $
 
14
# Revision 1.1  2004/01/02 18:50:00  jimmyo
 
15
# Renamed occurrances of lrrd -> munin
 
16
#
 
17
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
 
18
# Import of LRRD CVS tree after renaming to Munin
 
19
#
 
20
# Revision 1.3  2003/11/26 15:57:21  jimmyo
 
21
# Milliqueries not of interest...
 
22
#
 
23
# Revision 1.2  2003/11/26 14:47:31  jimmyo
 
24
# No peaks...
 
25
#
 
26
# Revision 1.1  2003/11/26 09:26:04  jimmyo
 
27
# Plugin contribution by Nicolai Langfeldt
 
28
#
 
29
 
30
#%# family=contrib
 
31
 
 
32
# REQUIREMENTS: in your named.conf you must have statistics-interval set:
 
33
# options {
 
34
#    ...
 
35
#    statistics-interval 1;
 
36
#    ...
 
37
# };
 
38
# The number is in minutes.  At each interval just 3 lines is dumped.
 
39
# It can be desturbing if you usually read the logs yourself, but
 
40
# a 1 minute interval ensures very updated information to munin.
 
41
# 5 minutes is the maximum I'd say.
 
42
 
 
43
# The name of the file where syslog puts daemon output - ie the named
 
44
# statistics output.  On solaris this is /var/adm/messages, on most
 
45
# linuxes it is /var/log/messages.  But on Debian it is
 
46
# /var/log/daemon which is read restricted so we have to run as a user
 
47
# with read rights, or remove the restrictions.
 
48
SYSLOGFILE=${logfile:-/var/adm/messages}
 
49
 
 
50
# ----------------------------------------------------------------------
 
51
 
 
52
pick_stat () {
 
53
    ret=`echo "$2" | sed "s/.*$1=\([0-9]*\).*/\1/"`
 
54
    if [ ! "$ret" ]; then
 
55
        echo 0;
 
56
    else
 
57
        echo $ret
 
58
    fi
 
59
}
 
60
 
 
61
do_stats () {
 
62
 
 
63
    if [ ! -f $SYSLOGFILE ] ; then 
 
64
        echo $SYSLOGFILE is unavailable to me >&2
 
65
        exit 1
 
66
    fi
 
67
 
 
68
    # Get out the last XSTATS and NSTATS lines
 
69
    XSTATS=`grep 'named.*XSTATS' "$SYSLOGFILE" | tail -1`
 
70
    # NSTATS=`grep 'named.*NSTATS' "$SYSLOGFILE" | tail -1`
 
71
 
 
72
    # We concentrate on what clients communicate with us about
 
73
    # and counters that we suspect can indicate abuse or error conditions
 
74
 
 
75
    # Received Queries: Total volume of queries received. 
 
76
    # This should be nice and smooth.
 
77
    echo "queries.value `pick_stat RQ "$XSTATS"`"
 
78
 
 
79
    # Sent Answers: This should be the same as RQ except when there are
 
80
    # errors.  May not be very interesting.
 
81
    echo "answers.value `pick_stat SAns "$XSTATS"`"
 
82
 
 
83
    # Sent and Forwarded queries, in a proxy setting this should be
 
84
    # the same as Received Queries (?)
 
85
    echo "forwarded.value `pick_stat SFwdQ "$XSTATS"`" 
 
86
 
 
87
    # Received Zone Transfer queries - should be low.  High value could
 
88
    # indicate some odd error or some kind of abuse
 
89
    echo "axfr.value `pick_stat RAXFR "$XSTATS"`"       # Received AXFR Qs
 
90
 
 
91
    # Received TCP connections: These are used for zone transfers or
 
92
    # oversized (>512 byte) answers.  A high value here could indicate
 
93
    # that you need to trim down the size of your answers somehow (Do you
 
94
    # have a ton of MXes or NSes that gets reported back?), or this could
 
95
    # be due to an error.  Or it could be due to abuse.
 
96
    echo "tcp.value `pick_stat RTCP "$XSTATS"`"
 
97
    
 
98
    # Get a total of errors
 
99
    errexpr="
 
100
            `pick_stat RNXD "$XSTATS"` +
 
101
            `pick_stat RFail "$XSTATS"` +
 
102
            `pick_stat RErr "$XSTATS"` +
 
103
            `pick_stat SErr "$XSTATS"` +
 
104
            `pick_stat RIQ "$XSTATS"` + 
 
105
            `pick_stat RFErr "$XSTATS"` ";
 
106
 
 
107
    echo "errors.value `expr $errexpr`"
 
108
}
 
109
 
 
110
case $1 in
 
111
    config)
 
112
        cat <<'EOF'
 
113
graph_title BIND DNS Query statistics
 
114
graph_vlabel Queries / minute
 
115
graph_scale no
 
116
queries.label Queries
 
117
queries.type DERIVE
 
118
queries.min 0
 
119
queries.cdef queries,60,*
 
120
answers.label Answers
 
121
answers.type DERIVE
 
122
answers.cdef answers,60,*
 
123
answers.min 0
 
124
forwarded.label Forwarded
 
125
forwarded.type DERIVE
 
126
forwarded.cdef forwarded,60,*
 
127
forwarded.min 0
 
128
axfr.label AXFRs
 
129
axfr.type DERIVE
 
130
axfr.cdef axfr,60,*
 
131
axfr.min 0
 
132
tcp.label Qs by TCP
 
133
tcp.type DERIVE
 
134
tcp.cdef tcp,60,*
 
135
tcp.min 0
 
136
errors.label Errors
 
137
errors.type DERIVE
 
138
errors.cdef errors,60,*
 
139
errors.min 0
 
140
EOF
 
141
        exit 0
 
142
        ;;
 
143
esac
 
144
 
 
145
do_stats
 
146