author | Peter Gervai <grin@grin.hu> |
Thu, 06 Nov 2008 14:46:59 +0100 | |
changeset 1 | 64825bf93a81 |
parent 0 | 55d66efee4e0 |
permissions | -rwxr-xr-x |
0
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
1 |
#!/bin/bash |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
2 |
# |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
3 |
# Added --fork compatibility to support multiple control sockets |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
4 |
# |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
5 |
# Original by ahu @ pdns-dev team |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
6 |
# Modified by Daniel Selans <dan.s at hostdime.com> |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
7 |
# 09.02.07 |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
8 |
# |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
9 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
10 |
SOCKETDIR=/var/run # Leave off the trailing slash |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
11 |
CHKFORK=`ps -C pdns_recursor --no-headers | wc -l` |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
12 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
13 |
# Quick sanity check |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
14 |
if [ CHKFORK = 0 ] |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
15 |
then |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
16 |
echo "pdns_recursor is not running!" |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
17 |
exit |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
18 |
fi |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
19 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
20 |
TSTAMP=$(date +%s) |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
21 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
22 |
VARIABLES="questions tcp-questions cache-entries concurrent-queries\ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
23 |
nxdomain-answers noerror-answers\ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
24 |
servfail-answers tcp-outqueries\ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
25 |
outgoing-timeouts nsspeeds-entries negcache-entries all-outqueries throttled-out\ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
26 |
cache-hits cache-misses answers0-1 answers1-10 answers10-100 answers100-1000 answers-slow\ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
27 |
qa-latency throttle-entries sys-msec user-msec unauthorized-udp unauthorized-tcp client-parse-errors\ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
28 |
server-parse-errors" |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
29 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
30 |
UVARIABLES=$(echo $VARIABLES | tr '[a-z]' '[A-Z]' | tr - _ ) |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
31 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
32 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
33 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
34 |
if [ $CHKFORK = 2 ] |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
35 |
then |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
36 |
# Running with --fork |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
37 |
SOCKETS=`ls -t -1 $SOCKETDIR/pdns_recursor.controlsocket.* | head --lines 2` |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
38 |
FORK="yes" |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
39 |
COUNT=0 |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
40 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
41 |
for i in $SOCKETS |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
42 |
do |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
43 |
PID=`echo $i | cut -d . -f3` |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
44 |
rec_control --socket-dir=$SOCKETDIR --socket-pid=$PID GET $VARIABLES | |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
45 |
( |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
46 |
for a in $UVARIABLES |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
47 |
do |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
48 |
read $a |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
49 |
done |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
50 |
rrdtool update pdns_recursor.$COUNT.rrd \ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
51 |
-t \ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
52 |
$(for a in $VARIABLES |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
53 |
do |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
54 |
echo -n $a: |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
55 |
done | sed 's/:$//' ) \ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
56 |
$TSTAMP$( |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
57 |
for a in $UVARIABLES |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
58 |
do |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
59 |
echo -n :${!a} |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
60 |
done) |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
61 |
) |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
62 |
COUNT=$(($COUNT + 1)) |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
63 |
done |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
64 |
|
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
65 |
else |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
66 |
rec_control --socket-dir=$SOCKETDIR GET $VARIABLES | |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
67 |
( |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
68 |
for a in $UVARIABLES |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
69 |
do |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
70 |
read $a |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
71 |
done |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
72 |
rrdtool update pdns_recursor.rrd \ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
73 |
-t \ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
74 |
$(for a in $VARIABLES |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
75 |
do |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
76 |
echo -n $a: |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
77 |
done | sed 's/:$//' ) \ |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
78 |
$TSTAMP$( |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
79 |
for a in $UVARIABLES |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
80 |
do |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
81 |
echo -n :${!a} |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
82 |
done) |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
83 |
) |
55d66efee4e0
First import from the web, original tgz seems to have lost
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
84 |
fi |