Cacti and the DNS (Bind) requests.... ?

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
Trest
Posts: 1
Joined: Sat Oct 25, 2003 9:52 am

Cacti and the DNS (Bind) requests.... ?

Post by Trest »

Hello has all,

I would like to use cacti for request DNS on Bind.
which are the parameters has to use for creation?

thank you in advance.

Trest.
Steve

Bind 9

Post by Steve »

This is a question many people would like answering.
Any ideas?
Step by step instructions?
Thanks in advance...
Headshock

DNS

Post by Headshock »

Hi, I have had no luck getting BIND 9 graphs working in cacti... I'm very new to cacti and just learned about it the other day, however I do have a somewhat working script to make an RRDtool graph of bind usage, however I never could get it to clear the stats so the graph always rises :) anyway here is what I used, let me know if anybody good with cacti could post some steps to make this work in that awesome interfaces

I have 4 files...
graphing.conf
named.sh
named_create.sh
named_graph.sh
I ran named_create.sh to create the rrd db, then
I call named.sh once a min and named_graphs.sh every 10 in my /etc/crontab file with this statement

Code: Select all

# create stats
* * * * * root  bash      /usr/local/bin/named.sh >/dev/null
#
*/10 * * * * root bash   /usr/local/bin/named_graphs.sh >/dev/null
Here are the files then
graphing.conf

Code: Select all

PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/rrdtool/bin
GRAPHS_DIRECTORY=/var/www/html/rrdtool/images
# Where your RRDtool are stored
DATABASE_DIRECTORY=/var/db/rrdtool
HOSTNAME='your.hostnamehere'
named.sh

Code: Select all

#!/bin/bash

source /etc/graphing.conf

TIMESTAMP=`date +%s`

/usr/sbin/rndc stats

NAMED=`tail -n 8 /var/named/named.stats | awk '{ print $2 }' | grep -v Statistics | sed 'i:' | tail -n 11 | tr -d '\012'`

NAMED=`echo $NAMED | sed s/\ //g`

rrdtool update $DATABASE_DIRECTORY/named.rrd $TIMESTAMP:$NAMED
The method to pull out the stats from var/named/named.stats is really crude but I just found soemthing that worked since I thought as soon as I figured out how to clear the stats i would need to change it anyway. At first I thoguth deleting the /var/named/named.stats file would work but next time rndc stats is run it comes back with the same numbers, infact the only way to clear them is to restart named, which is out of the question. :) Anywy the rest of the files....
named_create.sh

Code: Select all

#!/bin/bash

source /etc/graphing.conf

rrdtool create $DATABASE_DIRECTORY/named.rrd -s 60 \
        DS:successs:GAUGE:600:0:U \
        DS:referrals:GAUGE:600:0:U \
        DS:nxrrsets:GAUGE:600:0:U \
        DS:nxdomains:GAUGE:600:0:U \
        DS:recursions:GAUGE:600:0:U \
        DS:failures:GAUGE:600:0:U \
        RRA:AVERAGE:0.5:1:1440 \
        RRA:AVERAGE:0.5:26:404 \
        RRA:AVERAGE:0.5:116:400 \
        RRA:AVERAGE:0.5:1318:400 \
        RRA:MIN:0.5:1:1440 \
        RRA:MAX:0.5:1:1440 \
        RRA:MIN:0.5:26:400 \
        RRA:MAX:0.5:26:400 \
        RRA:MIN:0.5:116:400 \
        RRA:MAX:0.5:116:400 \
        RRA:MIN:0.5:1318:400 \
        RRA:MAX:0.5:1318:400
pretty basic....
named_graph.sh

Code: Select all

#!/bin/bash

source /etc/graphing.conf

RRDB=$DATABASE_DIRECTORY/named.rrd

NOW=`date +%s`
ONE_HOUR_AGO=$(($NOW-3600))
ONE_DAY_AGO=$(($NOW-86400))
ONE_WEEK_AGO=$(($NOW-604800))
ONE_MONTH_AGO=$(($NOW-2419200))
ONE_YEAR_AGO=$(($NOW-29030400))
TIMESTAMP="                   Generated on `date`"

function draw_graphic()
{
        rrdtool graph $GRAPHS_DIRECTORY/$1 -s $2 -e $3 -a PNG \
        -v Hits -t "NAMED Statistics for $4" \
        -r -u 500 -l -10 \
        DEF:success=$RRDB:successs:AVERAGE \
        DEF:referral=$RRDB:referrals:AVERAGE \
        DEF:nxrrset=$RRDB:nxrrsets:AVERAGE \
        DEF:nxdomain=$RRDB:nxdomains:AVERAGE \
        DEF:recursion=$RRDB:recursions:AVERAGE \
        DEF:failure=$RRDB:failures:AVERAGE \
        AREA:success#80ff80:"Success" \
        LINE1:success#00ff00 \
        LINE1:referral#c0c0c0:"nreferral" \
        LINE1:nxrrset#0000ff:"nxrrset" \
        LINE1:nxdomain#caf100:"nxdomain" \
        LINE1:recursion#837c04:"recursion" \
        LINE1:failure#ff0000:"failures" \
        COMMENT:"\n" \
        COMMENT:"$5\n"
}

draw_graphic 'named_day.png' $ONE_DAY_AGO $NOW "$HOSTNAME (last 24 hours)" "$TIMESTAMP"
draw_graphic 'named_week.png' $ONE_WEEK_AGO $NOW "$HOSTNAME (last week)" "$TIMESTAMP"
draw_graphic 'named_month.png' $ONE_MONTH_AGO $NOW "$HOSTNAME (last month)" "$TIMESTAMP"
draw_graphic 'named_year.png' $ONE_YEAR_AGO $NOW "$HOSTNAME (last year)" "$TIMESTAMP"
It works fine for me, but the graph keeps rising... :) If anybody has any input on how to clear the statistics let me know. Also if someone coudl whip up a quick step/step on how to add this into cacti, I have ver 0.84 Thanks and enjoy
Headshock

Found some info....

Post by Headshock »

I read that if you change the datatype to derive it should handle values that dont clear... can be performed to an existing database with... rrdtool tune -d failures:DERIVE
I did this with the 6 fields in my named.rrd, but it didnt seem to do anything...
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests