14th Dicembre 2007

Mrtg e monitoraggio DNS

La saga dei miei piccoli how-to sulle configurazioni di mrtg non finisce.

Questa volta mi serviva avere uno strumento per controllare il carico di lavoro del dns, dove per carico di lavoro non intento i carichi della CPU (già discussi nell’articolo sulla configurazione dell’snmp di questo sito).

Un buon parametro per effettuare questi contorlli su un DNS (Domain Name System) è il numero di query al minuto che vengono fatte, in tal modo è possibile avere una cronostoria e una rappresentazione di questo parametro che ci permette di valutare il numero delle richieste ed eventualmente evidenziare potenziali anomalie (es: un tetnativo di DDoS sulla porta 53 con un numero elevato di query).

Il numero di query sul dns non verrà generato a partire da un parametro snmp, bensì da uno script che effettua il parsing dei file di log del bind.

Per ottenere questi log dobbiamo modificare il file /etc/bind/named.conf.options (se avete un unico file probabilmente sarà /etc/named/named.conf o /etc/bind/named.conf) ed aggiungere le seguenti righe:

zone-statistics yes;
statistics-file "named.stats";

e rivviamo il named con

/etc/init.d/named restart

oppure

/etc/init.d/bind9 restart

a seconda della distribuzione che utilizzate. Ora all’interno del file /var/cache/bind/named.stats avrete delle statistiche sul numero di query per i singoli domini.

Il named ora è configurato correttamente, dobbiamo utilizzare i fati contenuti in nel file named.stats e utilizzarli con mrtg per generare i grafici.

Questo viene fatto utilizzando uno script (lo potete scaricare tramite wget).

Salviamo il file all’interno della cartella /etc/mrtg/ o dove avete le vostre configurazioni di mrtg ed editiamo il file /etc/mrtg/mymrtg.cfg aggiungendo quanto di seguito riportato

Target[mydomain_DNS]: `/etc/mrtg/dnsstats.pl`
Options[mydomain_DNS]: gauge,growright,nopercent,integer,unknaszero
Title[mydomain_DNS]: DNS Server
RouterUptime[mydomain_DNS]: public@localhost
MaxBytes[mydomain_DNS]: 32000
AbsMax[mydomain_DNS]: 64000
WithPeak[mydomain_DNS]: wmy
Colours[mydomain_DNS]: YELLOW #F9C000,RED #F90000,LIGHT YELLOW #FFFFBB,LIGTH RED #FF8080
ShortLegend[mydomain_DNS]:queries/m
YLegend[mydomain_DNS]: Qs per Minute
Legend1[mydomain_DNS]: Queries received over 1 minute
Legend2[mydomain_DNS]: Failed Queries received over 1 minute
Legend3[mydomain_DNS]: Maximal Queries over 5 minutes
Legend4[mydomain_DNS]: Maximal Failed Queries over 5 minutes
LegendI[mydomain_DNS]: Queries:
LegendO[mydomain_DNS]: Failures:
PageTop[mydomain_DNS]: <H1>DNS Info</H1><TABLE><TR><TD>System:</TD> <TD>mydomain</TD></TR><TR><TD>Maintainer:</TD> <TD>Matteo Temporini (temporini.matteo@gmail.com)</TD></TR><TR><TD>Description:</TD><TD>DNS Monitor</TD></TR><TR><TD>Details:</TD> <TD>Query Monitor</TD></TABLE>

Mi raccomando fate attenzione che l’ultimo parametro stia tutta sulla stessa riga o vi darà errore.

Ora non ci resta altro da fare che rigenerare l’index.html di mrtg con il nuovo parametro

indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg

e gustarci i nostri grafici che vedete qua sotto ;)

Dns Mrtg

This entry was posted on Venerdì, Dicembre 14th, 2007 at 10:16 am and is filed under CPU, DNS, Domain Name System, Matteo, Snmp, Uncategorized, linux, mrtg, networking, reti, server, servizi. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

There are currently 2 responses to “Mrtg e monitoraggio DNS”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On Gennaio 25th, 2008, alex said:

    il download di dnsstatspltar.gz contiene il file perl con questo contenuto:

    500 Internal Server Error

    Internal Server Error
    The server encountered an internal error or
    misconfiguration and was unable to complete
    your request.
    Please contact the server administrator,
    webmaster@temporini.net and inform them of the time the error occurred,
    and anything you might have done that may have
    caused the error.
    More information about this error may be available
    in the server error log.

  2. 2 On Gennaio 25th, 2008, admin said:

    Ciao alex, scusa ma ame funziona perfettamente il link in questione

    http://www.temporini.net/wp-content/uploads/2007/12/dnsstatspltar.gz

    fammi sapere se ti da ancora problemi, in caso mandami pure un’email a matteo@temporini.net che te lo spedisco via posta.

    Saluti

Leave a Reply

  • Pubblicità

  • Statistiche

  • Adsense