#!/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=800HSIZE=250# only recent rrds offer slope-mode:GRAPHOPTS=--slope-modefunctionmakeGraphs(){if[$MULTI=1]thenIMGFILEEND="$3.png"RRDFILEEND="$3.rrd"elseIMGFILEEND="png"RRDFILEEND="rrd"firrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/questions-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/tcp-questions-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/packet-errors-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/latencies-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/qoutq-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/qa-latency-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/timeouts-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/caches-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/caches2-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/load-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-v"MThreads"\-t"Concurrent queries"\DEF:concurrentqueries=pdns_recursor.$RRDFILEEND:concurrent-queries:AVERAGE\LINE1:concurrentqueries#0000ff:"concurrent queries"rrdtoolgraph$GRAPHOPTS--start-$1$WWWPREFIX/hitrate-$2.$IMGFILEEND-w$WSIZE-h$HSIZE-l0\-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-Cpdns_recursor--no-headers|wc-l`# Quick sanity checkif[CHKFORK=0]thenecho"pdns_recursor is not running!"exitfiif[$CHKFORK=2]thenCOUNT=0MULTI=1while[$COUNT!=$CHKFORK]domakeGraphs6h6h$COUNTmakeGraphs24hday$COUNT#makeGraphs 7d week $COUNT#makeGraphs 1m month $COUNT#makeGraphs 1y year $COUNTCOUNT=$(($COUNT+1))doneelseMULTI=0makeGraphs6h6hmakeGraphs24hday#makeGraphs 7d week#makeGraphs 1m month#makeGraphs 1y yearfi