Unless otherwise noted, all code herein is released under the GPL.
I graph my dnscache movement with MRTG. My /service/dnscache/log/run file contains:
#!/bin/sh exec setuidgid logging multilog t s10485760 n3 \ '-* cached *' '-* rr *' '-* tx *' /var/log/dnscache \ '-*' '+* stats *' =/var/log/dnscache/stats.log
This puts rotates three 1MB log files that contain no RR or TX records (my preference). The last line is the important one; it puts the most recent 'stats' line in the stats.log file. This is used by the script below:
#!/bin/sh exec head -n1 /var/log/dnscache/stats.log \ | awk '{ print $3"\n"$4"\n0\n0" }'
This script (I have it as /usr/bin/mrtg-dnscache.sh) outputs the query count and byte count in the way MRTG needs them for use with the following snippet from my mrtg.cfg:
Target[dnscache]: `/usr/bin/mrtg-dnscache.sh` Title[dnscache]: dnscache movement PageTop[dnscache]: <H1>dnscache</H1> ShortLegend[dnscache]: Bps MaxBytes[dnscache]: 10000000 YLegend[dnscache]: Bytes / Queries per second Legend1[dnscache]: Queries per second Legend2[dnscache]: Bytes per second Legend3[dnscache]: Max Queries/sec Legend4[dnscache]: Max Bytes/sec LegendI[dnscache]: Queries/sec LegendO[dnscache]: Bytes/sec Options[dnscache]: growright,noinfo Withpeak[dnscache]: dm
With the above, you should get a nice graph showing how much data and how many queries are passing through your dnscache installation like this: