Analiza BIND-9.2.4 statistika na RHEL 4U5

U mojim predhodnim postovima (ovde i ovde) je prikazano kako raditi statistiku i grafičku analizu za upite kada je u pitanju BIND-9.8.2.
Problem je u tome što ove dve verzije BIND-a daju POTPUNO različite statističke fajlove, tako da se za ovaj stariji analiza vrši totalno drugačije…..
Napomena : oblik statističkog fajla se menja od BIND verzije 9.6 pa na dalje.

Kako izgleda stats fajl za BIND-9.2 :
# more named_stats.txt
+++ Statistics Dump +++ (1400566931)
success 4344712
referral 0
nxrrset 813680
nxdomain 156930
recursion 1715096
failure 11745
— Statistics Dump — (1400566931)
Napomena : ovi brojači su KUMULATIVNI!!!! Dakle ne prazne se između dva upita.
Šta je šta u ovom fajlu :
success – The number of successful queries made to the server or zone. A successful query is defined as query which returns a NOERROR response with at least one answer RR.
referral – The number of queries which resulted in referral responses.
nxrrset – The number of queries which resulted in NOERROR responses with no data.
nxdomain – The number of queries which resulted in NXDOMAIN responses.
failure – The number of queries which resulted in a failure response other than those above.
recursion – The number of queries which caused the server to perform recursion in order to find the final answer. Recursion – the process a procedure goes through when one of the steps of the procedure involves invoking the procedure itself.

Primedba 1 : Each query received by the server will cause exactly one of success, referral, nxrrset, nxdomain, or failureto be incremented, and may additionally cause the recursion counter to be incremented.
Primedba 2 : queries = success + referral + nxrrset + nxdomain + failure
Ovo daje ukupan broj upita…..

Skripta za analizu DNS statistike :
#!/bin/bash
PATH=/bin/:/sbin:/usr/bin:/usr/sbin
###################################
TIME=5
datum=`date`
pocetnidir=/var/named/chroot/var/named/data
logfajl=$pocetnidir/dns.statistika.log
statistika=$pocetnidir/named_stats.txt
tmpfajl=$pocetnidir/tmpfajl
###################################
#analiza statistike BIND-a
###################################
echo /dev/null > $statistika
unset $success_staro
unset $success_novo
unset $success_razlika
unset $referral_staro
unset $referral_novo
unset $nxrrset_staro
unset $nxrrset_novo
unset $nxdomain_staro
unset $nxdomain_novo
unset $recursion_staro
unset $recursion_novo
unset $failure_staro
unset $failure_novo
unset $failure_razlika
################################
rndc stats
success_novo=`less $statistika|grep success|awk ‘{print $2}’`
failure_novo=`less $statistika|grep failure|awk ‘{print $2}’`
###############################
success_staro=`head -n1 $tmpfajl`
failure_staro=`tail -n1 $tmpfajl`
let success_razlika=$success_novo-$success_staro
let failure_razlika=$failure_novo-$failure_staro
echo $success_novo > $tmpfajl
echo $failure_novo >> $tmpfajl
##############################
echo $success_razlika
echo $failure_razlika

Kako izgleda mrtg.cfg fajl :
HtmlDir: /var/www/mrtg
ImageDir: /var/www/mrtg
LogDir: /var/lib/mrtg
ThreshDir: /var/lib/mrtg
Target[bind]: `/var/named/chroot/var/named/data/dns.statistika`
Title[bind]: DNS upiti
PageTop[bind]:

DNS upiti na 5min


LegendI[bind]: Dobrih upita na 5min
LegendO[bind]: Losih upita na 5min
Legend1[bind]: Dobrih upita na 5min
Legend2[bind]: Losih upita na 5min
Options[bind]: growright,pngdate,nobanner,gauge,nopercent,noinfo
ShortLegend[bind]: upiti/5min
Ylegend[bind]: Br upita
MaxBytes[bind]: 5000

Kako sve pokrenuti :
1. U /var/named/chroot/var/named/data napraviti tmpfajl1 i u njega staviti dve 0, jednu ispod druge (to je startni fajl).
Pustiti skriptu testa radi, i pratiti da li dobro radi.
2. DocumentRoot Apache-a mora da bude u /var/www
3. Otići u /var/www/mrtg i generisati index fajl :
# indexmaker –output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
4. Testirati sve :
# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
5. Ne stavljati NIŠTA u cron!!!!! Čak i uovoj prilično startoj verziji OS-a i MRTG-a i BIND-a, radiće i bez toga.