makegraphs
changeset 0 55d66efee4e0
equal deleted inserted replaced
-1:000000000000 0:55d66efee4e0
       
     1 #!/bin/bash
       
     2 #
       
     3 # Added --fork compatibility to support multiple control sockets
       
     4 #
       
     5 # Original by ahu @ pdns-dev team
       
     6 # Modified by Daniel Selans <dan.s at hostdime.com>
       
     7 # 09.02.07
       
     8 #
       
     9 
       
    10 WWWPREFIX=.
       
    11 WSIZE=800
       
    12 HSIZE=250
       
    13 
       
    14 # only recent rrds offer slope-mode:
       
    15 GRAPHOPTS=--slope-mode
       
    16 
       
    17 function makeGraphs()
       
    18 {
       
    19 
       
    20    if [ $MULTI = 1 ]
       
    21    then
       
    22          IMGFILEEND="$3.png"
       
    23          RRDFILEEND="$3.rrd"
       
    24    else
       
    25          IMGFILEEND="png"
       
    26          RRDFILEEND="rrd"
       
    27    fi
       
    28 
       
    29    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/questions-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
    30          -t "Questions and answers per second" \
       
    31          -v "packets" \
       
    32          DEF:questions=pdns_recursor.$RRDFILEEND:questions:AVERAGE  \
       
    33          DEF:nxdomainanswers=pdns_recursor.$RRDFILEEND:nxdomain-answers:AVERAGE \
       
    34          DEF:noerroranswers=pdns_recursor.$RRDFILEEND:noerror-answers:AVERAGE \
       
    35          DEF:servfailanswers=pdns_recursor.$RRDFILEEND:servfail-answers:AVERAGE \
       
    36          LINE1:questions#0000ff:"questions/s"\
       
    37          AREA:noerroranswers#00ff00:"noerror answers/s"  \
       
    38          STACK:nxdomainanswers#ffa500:"nxdomain answers/s"\
       
    39          STACK:servfailanswers#ff0000:"servfail answers/s"
       
    40 
       
    41    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/tcp-questions-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
    42          -t "TCP questions and answers per second, unauthorized packets/s" \
       
    43          -v "packets" \
       
    44          DEF:tcpquestions=pdns_recursor.$RRDFILEEND:tcp-questions:AVERAGE  \
       
    45          DEF:unauthudp=pdns_recursor.$RRDFILEEND:unauthorized-udp:AVERAGE  \
       
    46          DEF:unauthtcp=pdns_recursor.$RRDFILEEND:unauthorized-tcp:AVERAGE  \
       
    47          LINE1:tcpquestions#0000ff:"tcp questions/s" \
       
    48          LINE1:unauthudp#ff0000:"udp unauth/s"  \
       
    49          LINE1:unauthtcp#00ff00:"tcp unauth/s"
       
    50 
       
    51    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/packet-errors-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
    52          -t "Parsing errors per second" \
       
    53          -v "packets" \
       
    54          DEF:clientparseerrors=pdns_recursor.$RRDFILEEND:client-parse-errors:AVERAGE  \
       
    55          DEF:serverparseerrors=pdns_recursor.$RRDFILEEND:server-parse-errors:AVERAGE  \
       
    56          LINE1:clientparseerrors#0000ff:"bad packets from clients" \
       
    57          LINE1:serverparseerrors#00ff00:"bad packets from servers"
       
    58 
       
    59    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/latencies-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
    60          -t "Questions answered within latency" \
       
    61          -v "questions" \
       
    62          DEF:questions=pdns_recursor.$RRDFILEEND:questions:AVERAGE  \
       
    63          DEF:answers01=pdns_recursor.$RRDFILEEND:answers0-1:AVERAGE \
       
    64          DEF:answers110=pdns_recursor.$RRDFILEEND:answers1-10:AVERAGE \
       
    65          DEF:answers10100=pdns_recursor.$RRDFILEEND:answers10-100:AVERAGE \
       
    66          DEF:answers1001000=pdns_recursor.$RRDFILEEND:answers100-1000:AVERAGE \
       
    67          DEF:answersslow=pdns_recursor.$RRDFILEEND:answers-slow:AVERAGE \
       
    68          LINE1:questions#0000ff:"questions/s" \
       
    69          AREA:answers01#00ff00:"<1 ms" \
       
    70          STACK:answers110#0000ff:"<10 ms" \
       
    71          STACK:answers10100#00ffff:"<100 ms" \
       
    72          STACK:answers1001000#ffff00:"<1000 ms" \
       
    73          STACK:answersslow#ff0000:">1000 ms"
       
    74 
       
    75    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/qoutq-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0 \
       
    76          -t "Questions/outqueries per second" \
       
    77          -v "packets" \
       
    78          DEF:questions=pdns_recursor.$RRDFILEEND:questions:AVERAGE  \
       
    79          DEF:alloutqueries=pdns_recursor.$RRDFILEEND:all-outqueries:AVERAGE \
       
    80          LINE1:questions#ff0000:"questions/s"\
       
    81          LINE1:alloutqueries#00ff00:"outqueries/s"
       
    82 
       
    83    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/qa-latency-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0 \
       
    84          -t "Questions/answer latency in milliseconds" \
       
    85          -v "msec" \
       
    86          DEF:qalatency=pdns_recursor.$RRDFILEEND:qa-latency:AVERAGE  \
       
    87          CDEF:mqalatency=qalatency,1000,/ \
       
    88          LINE1:mqalatency#ff0000:"questions/s"
       
    89 
       
    90 
       
    91    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/timeouts-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
    92          -t "Outqueries/timeouts per second" \
       
    93          -v "events" \
       
    94          DEF:alloutqueries=pdns_recursor.$RRDFILEEND:all-outqueries:AVERAGE  \
       
    95          DEF:outgoingtimeouts=pdns_recursor.$RRDFILEEND:outgoing-timeouts:AVERAGE \
       
    96          DEF:throttledout=pdns_recursor.$RRDFILEEND:throttled-out:AVERAGE \
       
    97          LINE1:alloutqueries#ff0000:"outqueries/s"\
       
    98          LINE1:outgoingtimeouts#00ff00:"outgoing timeouts/s"\
       
    99          LINE1:throttledout#0000ff:"throttled outqueries/s"
       
   100 
       
   101 
       
   102    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/caches-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
   103          -t "Cache sizes" \
       
   104          -v "entries" \
       
   105          DEF:cacheentries=pdns_recursor.$RRDFILEEND:cache-entries:AVERAGE  \
       
   106          DEF:negcacheentries=pdns_recursor.$RRDFILEEND:negcache-entries:AVERAGE  \
       
   107          DEF:nsspeedsentries=pdns_recursor.$RRDFILEEND:nsspeeds-entries:AVERAGE  \
       
   108          DEF:throttleentries=pdns_recursor.$RRDFILEEND:throttle-entries:AVERAGE  \
       
   109          LINE1:cacheentries#ff0000:"cache entries" \
       
   110          LINE1:negcacheentries#0000ff:"negative cache entries" \
       
   111          LINE1:nsspeedsentries#00ff00:"NS speeds entries" \
       
   112          LINE1:throttleentries#00ff00:"throttle map entries"
       
   113 
       
   114 
       
   115    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/caches2-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
   116          -t "Cache sizes" \
       
   117          -v "entries" \
       
   118          DEF:negcacheentries=pdns_recursor.$RRDFILEEND:negcache-entries:AVERAGE  \
       
   119          DEF:nsspeedsentries=pdns_recursor.$RRDFILEEND:nsspeeds-entries:AVERAGE  \
       
   120          DEF:throttleentries=pdns_recursor.$RRDFILEEND:throttle-entries:AVERAGE  \
       
   121          LINE1:negcacheentries#0000ff:"negative cache entries" \
       
   122          LINE1:nsspeedsentries#00ff00:"NS speeds entries" \
       
   123          LINE1:throttleentries#ffa000:"throttle map entries"
       
   124 
       
   125    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/load-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
   126          -v "MThreads" \
       
   127          -t "Concurrent queries" \
       
   128          DEF:concurrentqueries=pdns_recursor.$RRDFILEEND:concurrent-queries:AVERAGE  \
       
   129          LINE1:concurrentqueries#0000ff:"concurrent queries"
       
   130 
       
   131    rrdtool graph $GRAPHOPTS --start -$1 $WWWPREFIX/hitrate-$2.$IMGFILEEND -w $WSIZE -h $HSIZE -l 0\
       
   132          -v "percentage" \
       
   133          -t "cache hits, cpu load" \
       
   134          DEF:cachehits=pdns_recursor.$RRDFILEEND:cache-hits:AVERAGE  \
       
   135          DEF:cachemisses=pdns_recursor.$RRDFILEEND:cache-misses:AVERAGE  \
       
   136          DEF:usermsec=pdns_recursor.$RRDFILEEND:user-msec:AVERAGE \
       
   137          DEF:sysmsec=pdns_recursor.$RRDFILEEND:sys-msec:AVERAGE \
       
   138          DEF:musermsec=pdns_recursor.$RRDFILEEND:user-msec:MAX \
       
   139          DEF:msysmsec=pdns_recursor.$RRDFILEEND:sys-msec:MAX \
       
   140          CDEF:perc=cachehits,100,*,cachehits,cachemisses,+,/ \
       
   141          CDEF:userperc=usermsec,10,/ \
       
   142          CDEF:sysperc=sysmsec,10,/ \
       
   143          CDEF:totmperc=musermsec,msysmsec,+,10,/ \
       
   144          LINE1:perc#0000ff:"percentage cache hits"  \
       
   145          LINE1:totmperc#ffff00:"max cpu use" \
       
   146          AREA:userperc#ff0000:"user cpu percentage" \
       
   147          STACK:sysperc#00ff00:"system cpu percentage" \
       
   148          COMMENT:"\l" \
       
   149          COMMENT:"Cache hits " \
       
   150          GPRINT:perc:AVERAGE:"avg %-3.1lf%%\t" \
       
   151          GPRINT:perc:LAST:"last %-3.1lf%%\t" \
       
   152          GPRINT:perc:MAX:"max %-3.1lf%%" \
       
   153          COMMENT:"\l" \
       
   154          COMMENT:"System cpu " \
       
   155          GPRINT:sysperc:AVERAGE:"avg %-3.1lf%%\t" \
       
   156          GPRINT:sysperc:LAST:"last %-3.1lf%%\t" \
       
   157          GPRINT:sysperc:MAX:"max %-3.1lf%%\t" \
       
   158          COMMENT:"\l" \
       
   159          COMMENT:"User cpu   " \
       
   160          GPRINT:userperc:AVERAGE:"avg %-3.1lf%%\t" \
       
   161          GPRINT:userperc:LAST:"last %-3.1lf%%\t" \
       
   162          GPRINT:userperc:MAX:"max %-3.1lf%%"
       
   163 
       
   164 }
       
   165 
       
   166 CHKFORK=`ps -C pdns_recursor --no-headers | wc -l`
       
   167 
       
   168 # Quick sanity check
       
   169 if [ CHKFORK = 0 ]
       
   170 then
       
   171          echo "pdns_recursor is not running!"
       
   172          exit
       
   173 fi
       
   174 
       
   175 if [ $CHKFORK = 2 ]
       
   176 then
       
   177          COUNT=0
       
   178          MULTI=1
       
   179          while [ $COUNT != $CHKFORK ]
       
   180          do
       
   181                  makeGraphs 6h 6h $COUNT
       
   182                  makeGraphs 24h day $COUNT
       
   183                  #makeGraphs 7d week $COUNT
       
   184                  #makeGraphs 1m month $COUNT
       
   185                  #makeGraphs 1y year $COUNT
       
   186                  COUNT=$(($COUNT + 1))
       
   187          done
       
   188 else
       
   189          MULTI=0
       
   190          makeGraphs 6h 6h
       
   191          makeGraphs 24h day
       
   192          #makeGraphs 7d week
       
   193          #makeGraphs 1m month
       
   194          #makeGraphs 1y year
       
   195 fi