<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Bind – Yeri Tiete</title>
    <link>https://yeri.be/tag/bind/</link>
    <description>Yeri Tiete&#39;s blog</description>
    <language>en</language>
    <copyright>© Yeri Tiete</copyright>
    <lastBuildDate>Sun, 13 Feb 2011 14:53:04 +0100</lastBuildDate>
    <atom:link href="https://yeri.be/tag/bind/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Bind mrtg stats</title>
      <link>https://yeri.be/bind-mrtg-stats/</link>
      <pubDate>Sun, 13 Feb 2011 14:53:04 +0100</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/bind-mrtg-stats/</guid>
      <description>&lt;p&gt;Because I couldn&amp;rsquo;t find any that worked.&lt;/p&gt;&#xA;&lt;p style=&#34;text-align: center;&#34;&gt;&lt;img class=&#34;alignnone size-full wp-image-2551&#34; title=&#34;bind-day&#34; src=&#34;https://static.yeri.be/2011/02/bind-day.png&#34; alt=&#34;&#34; width=&#34;500&#34; height=&#34;135&#34; /&gt;&lt;/p&gt;&#xA;&lt;p style=&#34;text-align: center;&#34;&gt;&lt;em&gt;(Dark blue: incoming queries, light blue: outgoing/recursive lookups)&lt;/em&gt;&lt;/p&gt;&#xA;mrtg.cfg sample:&#xA;&lt;pre style=&#34;background-color: #ffffff; line-height: 12pt; margin-right: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 35px; border: 1px dashed #489e06;&#34;&gt;# Bind&#xA;Title[bind]: Bind Queries&#xA;Target[bind]: `/etc/mrtg/bind-stats.sh`&#xA;PageTop[bind]: &amp;lt;H1&amp;gt; Bind queries per minute on vm1 &amp;lt;/H1&amp;gt;&#xA;Options[bind]: growright,pngdate,nobanner,gauge,nopercent,noinfo&#xA;MaxBytes[bind]: 50000&#xA;Ylegend[bind]: Queries/min&#xA;ShortLegend[bind]:  queries/min&#xA;LegendO[bind]: Incoming Bind queries per minute&#xA;LegendI[bind]: Outcoing Bind queries per minute&#xA;Legend2[bind]: Incoming Bind queries per minute&#xA;Legend1[bind]: Outcoing Bind queries per minute&lt;/pre&gt;&#xA;bind-stats.sh:&#xA;&lt;pre style=&#34;background-color: #ffffff; line-height: 12pt; margin-right: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 35px; border: 1px dashed #489e06;&#34;&gt;#!/bin/bash&#xA;# Bind MRTG stats&#xA;# by Yeri Tiete (Tuinslak) - 10/02/2011&#xA;# https://yeri.be&#xA;#&#xA;# mrtg.cfg sample:&#xA;################################################################################&#xA;#&#x9;#&#xA;#&#x9;# Bind&#xA;#&#x9;#&#xA;#&#x9;Title[bind]: Bind Queries&#xA;#&#x9;Target[bind]: `/etc/mrtg/bind-stats.sh`&#xA;#&#x9;PageTop[bind]: &amp;lt;H1&amp;gt; Bind queries per minute on vm1 &amp;lt;/H1&amp;gt;&#xA;#&#x9;Options[bind]: growright,pngdate,nobanner,gauge,nopercent,noinfo&#xA;#&#x9;MaxBytes[bind]: 50000&#xA;#&#x9;Ylegend[bind]: Queries/min&#xA;#&#x9;ShortLegend[bind]:  queries/min&#xA;#&#x9;LegendO[bind]: Incoming Bind queries per minute&#xA;#&#x9;LegendI[bind]: Outcoing Bind queries per minute&#xA;#&#x9;Legend2[bind]: Incoming Bind queries per minute&#xA;#&#x9;Legend1[bind]: Outcoing Bind queries per minute&#xA;################################################################################&#xA;&lt;h1 id=&#34;file-path-of-namedstats&#34;&gt;file path of named.stats&lt;/h1&gt;&#xA;&lt;p&gt;FILE=/var/log/named.stats&#xA;TMPFILE=/tmp/__dnsstats.txt&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Because I couldn&rsquo;t find any that worked.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-2551" title="bind-day" src="https://static.yeri.be/2011/02/bind-day.png" alt="" width="500" height="135" /></p>
<p style="text-align: center;"><em>(Dark blue: incoming queries, light blue: outgoing/recursive lookups)</em></p>
mrtg.cfg sample:
<pre style="background-color: #ffffff; line-height: 12pt; margin-right: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 35px; border: 1px dashed #489e06;"># Bind
Title[bind]: Bind Queries
Target[bind]: `/etc/mrtg/bind-stats.sh`
PageTop[bind]: &lt;H1&gt; Bind queries per minute on vm1 &lt;/H1&gt;
Options[bind]: growright,pngdate,nobanner,gauge,nopercent,noinfo
MaxBytes[bind]: 50000
Ylegend[bind]: Queries/min
ShortLegend[bind]:  queries/min
LegendO[bind]: Incoming Bind queries per minute
LegendI[bind]: Outcoing Bind queries per minute
Legend2[bind]: Incoming Bind queries per minute
Legend1[bind]: Outcoing Bind queries per minute</pre>
bind-stats.sh:
<pre style="background-color: #ffffff; line-height: 12pt; margin-right: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 35px; border: 1px dashed #489e06;">#!/bin/bash
# Bind MRTG stats
# by Yeri Tiete (Tuinslak) - 10/02/2011
# https://yeri.be
#
# mrtg.cfg sample:
################################################################################
#	#
#	# Bind
#	#
#	Title[bind]: Bind Queries
#	Target[bind]: `/etc/mrtg/bind-stats.sh`
#	PageTop[bind]: &lt;H1&gt; Bind queries per minute on vm1 &lt;/H1&gt;
#	Options[bind]: growright,pngdate,nobanner,gauge,nopercent,noinfo
#	MaxBytes[bind]: 50000
#	Ylegend[bind]: Queries/min
#	ShortLegend[bind]:  queries/min
#	LegendO[bind]: Incoming Bind queries per minute
#	LegendI[bind]: Outcoing Bind queries per minute
#	Legend2[bind]: Incoming Bind queries per minute
#	Legend1[bind]: Outcoing Bind queries per minute
################################################################################
<h1 id="file-path-of-namedstats">file path of named.stats</h1>
<p>FILE=/var/log/named.stats
TMPFILE=/tmp/__dnsstats.txt</p>
<h1 id="how-often-does-mrtg-run-for-me-its-every-10-mins">how often does mrtg run? for me it&rsquo;s every 10 mins</h1>
<p>TIME=10</p>
<h1 id="make-file-empty">make file empty</h1>
<p>echo /dev/null &gt; /var/log/named.stats</p>
<h1 id="generate-file">generate file</h1>
<p>/usr/sbin/rndc stats</p>
<h1 id="save-number-of-queries">save number of queries</h1>
<p>INNOW=<code>egrep &quot;[^I]QUERY&quot; $FILE | awk '{print $1 }'</code>
OUTNOW=<code>grep Outgoing $FILE -A 9 | sed '1,2d' | awk '{ SUM += $1} END { print SUM }'</code></p>
<h1 id="check-if-tmp-file-exists-and-insert-data-in-it-if-it-doesnt">check if tmp file exists and insert data in it if it doesnt</h1>
<h1 id="this-prevents-a-peak">this prevents a peak</h1>
<p>[ ! -e $TMPFILE ] &amp;&amp; echo $INNOW &gt; $TMPFILE &amp;&amp; echo $OUTNOW &gt;&gt; $TMPFILE</p>
<h1 id="get-old-data">get old data</h1>
<p>INOLD=<code>cat $TMPFILE | sed -n 1p</code>
OUTOLD=<code>cat $TMPFILE | sed -n 2p</code></p>
<h1 id="overwrite-old">overwrite old</h1>
<p>echo $INNOW &gt; $TMPFILE
echo $OUTNOW &gt;&gt; $TMPFILE</p>
<h1 id="calculate-to-get-difference">calculate (to get difference)</h1>
<p>INDIFF=$[ $INNOW-$INOLD ]
OUTDIFF=$[ $OUTNOW-$OUTOLD ]</p>
<h1 id="as-mrtg-runs-10--divide-by-10-to-get-per-minute">as mrtg runs */10 &gt; divide by 10 to get per minute</h1>
<p>INPERMIN=$[ $INDIFF/$TIME ]
OUTPERMIN=$[ $OUTDIFF/$TIME ]</p>
<h1 id="print-">print !</h1>
<p>echo $OUTPERMIN
echo $INPERMIN
echo
echo</pre>
Or download the file <a href="https://static.yeri.be/2011/02/bind-stats.sh.txt" target="_blank" rel="noopener noreferrer">riiiiiight here</a>.</p>
<p>Be sure the named.stats file gives this kind of output:</p>
<pre style="background-color: #ffffff; line-height: 12pt; margin-right: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 35px; border: 1px dashed #489e06;"># grep Outgoing /var/log/named.stats -A 9
++ Outgoing Queries ++
[View: default]
               64316 A
                   2 NS
                  22 SOA
                6945 PTR
                 892 MX
                1104 TXT
                3117 AAAA
                  22 SRV</pre>
<p>&hellip; for the outgoing queries, and &hellip;</p>
<pre style="background-color: #ffffff; line-height: 12pt; margin-right: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 35px; border: 1px dashed #489e06;"># grep QUERY /var/log/named.stats | awk '{print $1 }'
163143</pre>
<p>for the incoming queries.</p>
<p>Don&rsquo;t forget to</p>
<pre style="background-color: #ffffff; line-height: 12pt; margin-right: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 35px; border: 1px dashed #489e06;">chmod +x bind-stats.sh</pre>
<p>Live sample: <a href="http://vm1.rootspirit.com/mrtg/bind.html" target="_blank" rel="noopener noreferrer">vm1.rootspirit.com/mrtg/bind.html</a></p>
]]></content:encoded>
      <category>Linux</category><category>Software</category><category>www</category>
      <category>bind</category><category>dns</category><category>mrtg</category>
    </item>
    
  </channel>
</rss>
