makegraphs
author Peter Gervai <grin@grin.hu>
Thu, 06 Nov 2008 15:14:14 +0100
changeset 2 5d3d6a4a6c9d
parent 0 55d66efee4e0
permissions -rwxr-xr-x
Adding index*.html pages

#!/bin/bash
#
# Added --fork compatibility to support multiple control sockets
#
# Original by ahu @ pdns-dev team
# Modified by Daniel Selans <dan.s at hostdime.com>
# 09.02.07
#

WWWPREFIX=.
WSIZE=800
HSIZE=250

# only recent rrds offer slope-mode:
GRAPHOPTS=--slope-mode

function makeGraphs()
{

   if [ $MULTI = 1 ]
   then
         IMGFILEEND="$3.png"
         RRDFILEEND="$3.rrd"
   else
         IMGFILEEND="png"
         RRDFILEEND="rrd"
   fi

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/questions-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -t "Questions and answers per second" \
         -v "packets" \
         DEF:questions=pdns_recursor.$RRDFILEEND:questions:AVERAGE  \
         DEF:nxdomainanswers=pdns_recursor.$RRDFILEEND:nxdomain-answers:AVERAGE \
         DEF:noerroranswers=pdns_recursor.$RRDFILEEND:noerror-answers:AVERAGE \
         DEF:servfailanswers=pdns_recursor.$RRDFILEEND:servfail-answers:AVERAGE \
         LINE1:questions#0000ff:"questions/s"\
         AREA:noerroranswers#00ff00:"noerror answers/s"  \
         STACK:nxdomainanswers#ffa500:"nxdomain answers/s"\
         STACK:servfailanswers#ff0000:"servfail answers/s"

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/tcp-questions-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -t "TCP questions and answers per second, unauthorized packets/s" \
         -v "packets" \
         DEF:tcpquestions=pdns_recursor.$RRDFILEEND:tcp-questions:AVERAGE  \
         DEF:unauthudp=pdns_recursor.$RRDFILEEND:unauthorized-udp:AVERAGE  \
         DEF:unauthtcp=pdns_recursor.$RRDFILEEND:unauthorized-tcp:AVERAGE  \
         LINE1:tcpquestions#0000ff:"tcp questions/s" \
         LINE1:unauthudp#ff0000:"udp unauth/s"  \
         LINE1:unauthtcp#00ff00:"tcp unauth/s"

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/packet-errors-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -t "Parsing errors per second" \
         -v "packets" \
         DEF:clientparseerrors=pdns_recursor.$RRDFILEEND:client-parse-errors:AVERAGE  \
         DEF:serverparseerrors=pdns_recursor.$RRDFILEEND:server-parse-errors:AVERAGE  \
         LINE1:clientparseerrors#0000ff:"bad packets from clients" \
         LINE1:serverparseerrors#00ff00:"bad packets from servers"

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/latencies-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -t "Questions answered within latency" \
         -v "questions" \
         DEF:questions=pdns_recursor.$RRDFILEEND:questions:AVERAGE  \
         DEF:answers01=pdns_recursor.$RRDFILEEND:answers0-1:AVERAGE \
         DEF:answers110=pdns_recursor.$RRDFILEEND:answers1-10:AVERAGE \
         DEF:answers10100=pdns_recursor.$RRDFILEEND:answers10-100:AVERAGE \
         DEF:answers1001000=pdns_recursor.$RRDFILEEND:answers100-1000:AVERAGE \
         DEF:answersslow=pdns_recursor.$RRDFILEEND:answers-slow:AVERAGE \
         LINE1:questions#0000ff:"questions/s" \
         AREA:answers01#00ff00:"<1 ms" \
         STACK:answers110#0000ff:"<10 ms" \
         STACK:answers10100#00ffff:"<100 ms" \
         STACK:answers1001000#ffff00:"<1000 ms" \
         STACK:answersslow#ff0000:">1000 ms"

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/qoutq-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0 \
         -t "Questions/outqueries per second" \
         -v "packets" \
         DEF:questions=pdns_recursor.$RRDFILEEND:questions:AVERAGE  \
         DEF:alloutqueries=pdns_recursor.$RRDFILEEND:all-outqueries:AVERAGE \
         LINE1:questions#ff0000:"questions/s"\
         LINE1:alloutqueries#00ff00:"outqueries/s"

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/qa-latency-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0 \
         -t "Questions/answer latency in milliseconds" \
         -v "msec" \
         DEF:qalatency=pdns_recursor.$RRDFILEEND:qa-latency:AVERAGE  \
         CDEF:mqalatency=qalatency,1000,/ \
         LINE1:mqalatency#ff0000:"questions/s"


   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/timeouts-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -t "Outqueries/timeouts per second" \
         -v "events" \
         DEF:alloutqueries=pdns_recursor.$RRDFILEEND:all-outqueries:AVERAGE  \
         DEF:outgoingtimeouts=pdns_recursor.$RRDFILEEND:outgoing-timeouts:AVERAGE \
         DEF:throttledout=pdns_recursor.$RRDFILEEND:throttled-out:AVERAGE \
         LINE1:alloutqueries#ff0000:"outqueries/s"\
         LINE1:outgoingtimeouts#00ff00:"outgoing timeouts/s"\
         LINE1:throttledout#0000ff:"throttled outqueries/s"


   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/caches-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -t "Cache sizes" \
         -v "entries" \
         DEF:cacheentries=pdns_recursor.$RRDFILEEND:cache-entries:AVERAGE  \
         DEF:negcacheentries=pdns_recursor.$RRDFILEEND:negcache-entries:AVERAGE  \
         DEF:nsspeedsentries=pdns_recursor.$RRDFILEEND:nsspeeds-entries:AVERAGE  \
         DEF:throttleentries=pdns_recursor.$RRDFILEEND:throttle-entries:AVERAGE  \
         LINE1:cacheentries#ff0000:"cache entries" \
         LINE1:negcacheentries#0000ff:"negative cache entries" \
         LINE1:nsspeedsentries#00ff00:"NS speeds entries" \
         LINE1:throttleentries#00ff00:"throttle map entries"


   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/caches2-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -t "Cache sizes" \
         -v "entries" \
         DEF:negcacheentries=pdns_recursor.$RRDFILEEND:negcache-entries:AVERAGE  \
         DEF:nsspeedsentries=pdns_recursor.$RRDFILEEND:nsspeeds-entries:AVERAGE  \
         DEF:throttleentries=pdns_recursor.$RRDFILEEND:throttle-entries:AVERAGE  \
         LINE1:negcacheentries#0000ff:"negative cache entries" \
         LINE1:nsspeedsentries#00ff00:"NS speeds entries" \
         LINE1:throttleentries#ffa000:"throttle map entries"

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/load-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -v "MThreads" \
         -t "Concurrent queries" \
         DEF:concurrentqueries=pdns_recursor.$RRDFILEEND:concurrent-queries:AVERAGE  \
         LINE1:concurrentqueries#0000ff:"concurrent queries"

   rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/hitrate-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
         -v "percentage" \
         -t "cache hits, cpu load" \
         DEF:cachehits=pdns_recursor.$RRDFILEEND:cache-hits:AVERAGE  \
         DEF:cachemisses=pdns_recursor.$RRDFILEEND:cache-misses:AVERAGE  \
         DEF:usermsec=pdns_recursor.$RRDFILEEND:user-msec:AVERAGE \
         DEF:sysmsec=pdns_recursor.$RRDFILEEND:sys-msec:AVERAGE \
         DEF:musermsec=pdns_recursor.$RRDFILEEND:user-msec:MAX \
         DEF:msysmsec=pdns_recursor.$RRDFILEEND:sys-msec:MAX \
         CDEF:perc=cachehits,100,*,cachehits,cachemisses,+,/ \
         CDEF:userperc=usermsec,10,/ \
         CDEF:sysperc=sysmsec,10,/ \
         CDEF:totmperc=musermsec,msysmsec,+,10,/ \
         LINE1:perc#0000ff:"percentage cache hits"  \
         LINE1:totmperc#ffff00:"max cpu use" \
         AREA:userperc#ff0000:"user cpu percentage" \
         STACK:sysperc#00ff00:"system cpu percentage" \
         COMMENT:"\l" \
         COMMENT:"Cache hits " \
         GPRINT:perc:AVERAGE:"avg %-3.1lf%%\t" \
         GPRINT:perc:LAST:"last %-3.1lf%%\t" \
         GPRINT:perc:MAX:"max %-3.1lf%%" \
         COMMENT:"\l" \
         COMMENT:"System cpu " \
         GPRINT:sysperc:AVERAGE:"avg %-3.1lf%%\t" \
         GPRINT:sysperc:LAST:"last %-3.1lf%%\t" \
         GPRINT:sysperc:MAX:"max %-3.1lf%%\t" \
         COMMENT:"\l" \
         COMMENT:"User cpu   " \
         GPRINT:userperc:AVERAGE:"avg %-3.1lf%%\t" \
         GPRINT:userperc:LAST:"last %-3.1lf%%\t" \
         GPRINT:userperc:MAX:"max %-3.1lf%%"

}

CHKFORK=`ps -C pdns_recursor --no-headers | wc -l`

# Quick sanity check
if [ CHKFORK = 0 ]
then
         echo "pdns_recursor is not running!"
         exit
fi

if [ $CHKFORK = 2 ]
then
         COUNT=0
         MULTI=1
         while [ $COUNT != $CHKFORK ]
         do
                 makeGraphs 6h 6h $COUNT
                 makeGraphs 24h day $COUNT
                 #makeGraphs 7d week $COUNT
                 #makeGraphs 1m month $COUNT
                 #makeGraphs 1y year $COUNT
                 COUNT=$(($COUNT + 1))
         done
else
         MULTI=0
         makeGraphs 6h 6h
         makeGraphs 24h day
         #makeGraphs 7d week
         #makeGraphs 1m month
         #makeGraphs 1y year
fi