BIND 9 Statistics for Cacti

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
6ibPeter
Posts: 4
Joined: Sat Jan 10, 2009 7:04 am

Post by 6ibPeter »

The above solution worked for me: i can get my statistics now via snmp and when i execute

Code: Select all

snmpwalk -v 1 -c {community} {ip address} .1.3.6.1.4.1.2021.55
i receive the data.
But when i use cacti, it doesn't show the data in the graphs, it keeps displaying all zero's in the legenda and there is no graph displayed.
When i set my log level on debug i noticed several warnings like this

Code: Select all

01/18/2009 02:30:01 AM - CMDPHP: Poller[0] DEBUG: SQL Exec: "insert into poller_output (local_data_id, rrd_name, time, output) values (40, 'nxrrset', '2009-01-18 02:30:01', 'U')"
01/18/2009 02:30:01 AM - CMDPHP: Poller[0] Host[2] DS[40] SNMP: v1: 127.0.0.1, dsname: nxrrset, oid: , output: U
01/18/2009 02:30:01 AM - CMDPHP: Poller[0] Host[2] DS[40] WARNING: Result from SNMP not valid. Partial Result:
01/18/2009 02:30:01 AM - CMDPHP: Poller[0] DEBUG: SQL Exec: "insert into poller_output (local_data_id, rrd_name, time, output) values (39, 'failure', '2009-01-18 02:30:01', 'U')"
01/18/2009 02:30:01 AM - CMDPHP: Poller[0] Host[2] DS[39] SNMP: v1: 127.0.0.1, dsname: failure, oid: , output: U
01/18/2009 02:30:01 AM - CMDPHP: Poller[0] Host[2] DS[39] WARNING: Result from SNMP not valid. Partial Result:
EDIT: i recompiled php with the socket USE flag (i use gentoo) and now the above errors are gone, but i still have the problem that the values in my graph stay at zero. any ideas?
JeffRoberson
Posts: 7
Joined: Fri Jan 16, 2009 3:52 pm

Post by JeffRoberson »

It's interesting that it is looking at 127.0.0.1 and not the host. You might check to see if it is pulling the data from the correct host.
6ibPeter
Posts: 4
Joined: Sat Jan 10, 2009 7:04 am

Post by 6ibPeter »

JeffRoberson wrote:It's interesting that it is looking at 127.0.0.1 and not the host. You might check to see if it is pulling the data from the correct host.
Sorry I forgot to mention this,
It's the localhost where i'm pulling the stats of. Thanks to the script you posted earlier in this thread :)
JeffRoberson
Posts: 7
Joined: Fri Jan 16, 2009 3:52 pm

Post by JeffRoberson »

Ah, there is a different set of scripts that the original author posted to pull local stats. I'll look over that code and see if I can modify it to work for the local hosts for you.
6ibPeter
Posts: 4
Joined: Sat Jan 10, 2009 7:04 am

Post by 6ibPeter »

JeffRoberson wrote:Ah, there is a different set of scripts that the original author posted to pull local stats. I'll look over that code and see if I can modify it to work for the local hosts for you.
Thanks i'd really appreciate it :)
JeffRoberson
Posts: 7
Joined: Fri Jan 16, 2009 3:52 pm

Post by JeffRoberson »

Here is the tweaked up code for the bind9-stats.pl script for local checks. I created a table to translate the BIND 9 stats to BIND 8 stats. I think that I'm hitting the correct new names to the old ones. Please feel free to correct me if I'm wrong. The main loop is similar to the one that I modified for the SNMPD checks.

Code: Select all

#!/usr/bin/perl

#
# Script to parse bind9 stats file for cacti
#
# Local Checks
#
# Created By: Cory Powers <cory@uversaconsulting.net>
# Modified By: Jeff Roberson <jroberson@bethelks.edu>
#

$STAT_FILE = "/var/cache/bind/named.stats";

$ids{'responses sent'} = 'index';
$ids{'queries resulted in authoritative answer'} = 'name';
$ids{'queries resulted in successful answer'} = 'success';
$ids{'other query failures'} = 'failure';
$ids{'queries resulted in NXDOMAIN'} = 'nxdomain';
$ids{'queries resulted in nxrrset'} = 'nxrrset';
$ids{'queries resulted in non authoritative answer'} = 'referral';
$ids{'queries caused recursion'} = 'recursion';

process_stats();

$mode = lc(shift(@ARGV));
if($mode =~ /^query$/){
	$req_stat = lc(shift(@ARGV));
	dumpstats($req_stat);
}elsif($mode =~ /^index$/){
	dumpindexes();
}elsif($mode =~ /^snmpd$/){
	dumpsnmpdata();
}elsif($mode =~ /^get$/){
	$req_stat = lc(shift(@ARGV));
	$req_zone = join(" ", @ARGV);
	$req_zone = prepareindex($req_zone);
	getstat($req_zone, $req_stat);
}elsif($mode =~ /^getall$/){
	$req_zone = join(" ", @ARGV);
	$req_zone = prepareindex($req_zone);
	getallstats($req_zone);
}elsif($mode =~ /^dump$/){
	dumpdata();
}else{
	print_usage();
	exit(2);
}

exit(0);

sub print_usage{
	print("
Ways to use bind9-stats.pl:
bind9-stats.pl index
  Retreive list of all indexes
bind9-stats.pl query (zone|recursion|success|failure|nxrrset|referral|nxdomain)
  Get specified statistic for all indexes
bind9-stats.pl get (recursion|success|failure|nxrrset|referral|nxdomain) INDEX
 Get specified statistic for index INDEX
bind9-stats.pl getall INDEX
 Get all statistics for index INDEX

");
}

sub process_stats{
	# Die unless we can locate the stats file
	if (!open(STATS,$STAT_FILE)) {
			die "Failed to open $STAT_FILE: $!\n";
	}


	while(<STATS>){
              if (/(.+)\ Name\ Server\ Statistics./) {
                        $zone="GLOBAL";
                }
                next if /^[\-\+]/;
                next if /^\s*$/;
                next if /\[View./;
                next if /\[Common./;
                if (/\[(.+)\]/) {
                        $zone=prepareindex($1);
                }elsif (/^(\s+) (\d+) (.*)$/) {
			$stat=$ids{$3};
			if ($stat ne "") {
				if ($zone eq "GLOBAL") {
					$stats_global{$stat} = $2;
				} else {
					$stats_zone{$zone}{$stat} = $2;
				}
			}
		}
	}
	close(STATS);
}

sub prepareindex{
	$input = shift @_;

	for ($input) {
		s/^\s+//;
		s/\s+$//;
		s/\s/_/;
	}
	return $input
}

sub dumpsnmpdata{
	foreach $stat (keys(%stats_global)) {
		print "GLOBAL.$stat = $stats_global{$stat}\n";
	}

	print("\nNumber of zones: ".keys(%stats_zone)."\n\n");
	foreach $zone (keys(%stats_zone)) {
		foreach $stat (keys(%{$stats_zone{$zone}})) {
			print("$zone.$stat=".$stats_zone{$zone}{$stat}."\n");
		}
	}
}

sub dumpdata{
	print("Global Stat Count: ".keys(%stats_global)."\n");

	foreach $stat (keys(%stats_global)) {
		print "$stat = $stats_global{$stat}\n";
	}

	print("\nNumber of zones: ".keys(%stats_zone)."\n\n");
	foreach $zone (keys(%stats_zone)) {
		print("Zone: ".$zone."\n");
		foreach $stat (keys(%{$stats_zone{$zone}})) {
			print("$stat:".$stats_zone{$zone}{$stat}."\n");
		}
	}
}

sub dumpindexes{
	print("GLOBAL\n");

	foreach $zone (keys(%stats_zone)) {
		print("$zone\n");
	}
}

sub dumpstats{
	$req_stat = shift(@_);

	if($req_stat =~ /zone/){
		print("GLOBAL:GLOBAL\n");
		foreach $zone (keys(%stats_zone)) {
			print("$zone:$zone\n");
		}
	}else{

		print("GLOBAL:".$stats_global{$req_stat}."\n");

		foreach $zone (keys(%stats_zone)) {
			print("$zone:".$stats_zone{$zone}{$req_stat}."\n");
		}
	}
}

sub getstat{
	$req_zone = shift(@_);
	$req_stat = shift(@_);

	if($req_zone =~ /GLOBAL/){
		print($stats_global{$req_stat});
	}else{
		print($stats_zone{$req_zone}{$req_stat});
	}
}

sub getallstats{
	$req_zone = shift(@_);

	if($req_zone =~ /GLOBAL/){
		foreach $stat (keys(%stats_global)) {
			print "$stat:$stats_global{$stat} ";
		}
	}else{
		foreach $stat (keys(%{$stats_zone{$req_zone}})) {
			print("$stat:".$stats_zone{$req_zone}{$stat}." ");
		}
	}
}
LAtino
Posts: 1
Joined: Thu Jan 22, 2009 1:33 pm

Ineed

Post by LAtino »

I need templates for cacti that are compacted into xml gz or tgz I use debian linux...plis
JeffRoberson
Posts: 7
Joined: Fri Jan 16, 2009 3:52 pm

Bind9-stats-2.0.tar

Post by JeffRoberson »

Here is a refreshed tar file with the new scripts and the other files created by Cory Powers. Enjoy!
Attachments
bind9-stats-2.0.tar
(80 KiB) Downloaded 4960 times
6ibPeter
Posts: 4
Joined: Sat Jan 10, 2009 7:04 am

Re: Bind9-stats-2.0.tar

Post by 6ibPeter »

JeffRoberson wrote:Here is a refreshed tar file with the new scripts and the other files created by Cory Powers. Enjoy!
Thanks! works perfect :D
Loup Artic
Posts: 8
Joined: Wed Jul 09, 2008 5:20 pm
Location: En cage à la S.P.A

Post by Loup Artic »

Dear,

I install new packages but, im a problem.

Code: Select all

Data Query Debug Information 
 
+ Running data query [12].
+ Found type = '4 '[script query].
+ Found data query XML file at '/var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/resource/script_queries/bind9-stats.xml'
+ XML file parsed ok.
+ Executing script for list of indexes 'perl /var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/scripts/bind9-stats.pl index'
+ Executing script query 'perl /var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/scripts/bind9-stats.pl query zone'
+ Found data query XML file at '/var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/resource/script_queries/bind9-stats.xml'
+ Found data query XML file at '/var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/resource/script_queries/bind9-stats.xml'
+ Found data query XML file at '/var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/resource/script_queries/bind9-stats.xml'
 

Code: Select all

) BIND 9 Statistics  (Verbose Query)  Uptime Goes Backwards  Success [0 Items, 0 Rows]  
If use :

Code: Select all

perl /var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/scripts/bind9-stats.pl query zone

Respond : GLOBAL:GLOBAL
What is the problem in my conf ?

Thanks :).
JeffRoberson
Posts: 7
Joined: Fri Jan 16, 2009 3:52 pm

Post by JeffRoberson »

Check the permissions of perl /var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/scripts/bind9-stats.pl. Permissions can usually cause problems like this.

Also, check to see where your bind9 stats file is located. You may need to adjust the script to point to the correct location of your stats file.
kirgudu
Posts: 10
Joined: Wed Feb 04, 2009 4:22 am
Location: Moscow, Russia

Post by kirgudu »

JeffRoberson wrote:Check the permissions of perl /var/www/vhosts/free-h.org/subdomains/panel/httpdocs/cacti/scripts/bind9-stats.pl. Permissions can usually cause problems like this.

Also, check to see where your bind9 stats file is located. You may need to adjust the script to point to the correct location of your stats file.
Hm... I have same problem. i use statistic via snmp.

Code: Select all

Data Query Debug Information
+ Running data query [10].
+ Found type = '3' [snmp query].
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/bind9-stats-snmp.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.2021.55.1'
+ No SNMP data returned
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/bind9-stats-snmp.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/bind9-stats-snmp.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/bind9-stats-snmp.xml'

Code: Select all

snmpwalk -v2c  -c COMMUNITI SERVER .1.3.6.1.4.1.2021.55
UCD-SNMP-MIB::ucdavis.55.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.55.2.1 = STRING: "GLOBAL"
UCD-SNMP-MIB::ucdavis.55.3.1 = INTEGER: 1786984
UCD-SNMP-MIB::ucdavis.55.4.1 = INTEGER: 1066596
UCD-SNMP-MIB::ucdavis.55.5.1 = INTEGER: 1043871
UCD-SNMP-MIB::ucdavis.55.6.1 = INTEGER: 172884
UCD-SNMP-MIB::ucdavis.55.7.1 = INTEGER: 2552988
UCD-SNMP-MIB::ucdavis.55.8.1 = INTEGER: 1386117
bind-9.6-p1

Code: Select all

+++ Statistics Dump +++ (1233738626)
++ Incoming Requests ++
             4440806 QUERY
                  94 NOTIFY
                2034 UPDATE
++ Incoming Queries ++
                   9 RESERVED0
             2182920 A
               11312 NS
                3209 CNAME
               11254 SOA
             1633789 PTR
              285284 MX
              135306 TXT
              139344 AAAA
               14422 SRV
                  11 NAPTR
               15445 A6
                1845 SPF
                 905 TKEY
                5418 ANY
++ Outgoing Queries ++
[View: default]
                   1 RESERVED0
             1217207 A
                5587 NS
                1512 CNAME
                5229 SOA
              316124 PTR
              248083 MX
              146043 TXT
              301922 AAAA
                2550 SRV
                   3 NAPTR
                7395 A6
                1168 SPF
                2793 ANY
[View: _bind]
++ Name Server Statistics ++
             4453763 IPv4 requests received
              979150 requests with EDNS(0) received
                1085 TCP requests received
               92337 auth queries rejected
              196259 recursive queries rejected
                3986 update requests rejected
             4375051 responses sent
                 253 truncated responses sent
              978109 responses with EDNS(0) sent
             1786984 queries resulted in successful answer
              453949 queries resulted in authoritative answer
             2552988 queries resulted in non authoritative answer
                3198 queries resulted in referral answer
              172884 queries resulted in nxrrset
             1066596 queries resulted in SERVFAIL
             1043871 queries resulted in NXDOMAIN
             1386117 queries caused recursion
               35342 duplicate queries received
               41345 queries dropped
              289166 other query failures
                  12 updates failed
                  12 updates rejected due to prerequisite failure
++ Zone Maintenance Statistics ++
                2809 IPv4 notifies sent
                   9 IPv4 notifies received
               31102 IPv4 SOA queries sent
                  94 IPv4 AXFR requested
                  10 IPv4 IXFR requested
                   9 transfer requests succeeded
                  99 transfer requests failed
++ Resolver Statistics ++
[Common]
                2481 mismatch responses received
[View: default]
             2061532 IPv4 queries sent
              194085 IPv6 queries sent
             1454995 IPv4 responses received
              282708 NXDOMAIN received
               65138 SERVFAIL received
               10044 FORMERR received
               77548 other errors received
               24497 EDNS(0) query failures
                4420 truncated responses received
               28782 lame delegations received
              888248 query retries
               60816 IPv4 NS address fetches
               77371 IPv6 NS address fetches
                3303 IPv4 NS address fetch failed
               75960 IPv6 NS address fetch failed
[View: _bind]
++ Cache DB RRsets ++
[View: default]
              272963 A
              222233 NS
               23235 CNAME
                 370 SOA
               68033 PTR
                   2 HINFO
               70026 MX
               16732 TXT
                   3 RP
                1177 AAAA
                   1 LOC
                  21 SRV
                   9 DNAME
                  52 DS
               24121 RRSIG
               23101 NSEC
                   1 DNSKEY
                   2 SPF
                2723 !A
                  22 !NS
                 104 !CNAME
                  22 !SOA
                  14 !PTR
                2456 !MX
                8763 !TXT
               48880 !AAAA
                  49 !SRV
                   3 !NAPTR
                1699 !A6
                 584 !SPF
              125505 NXDOMAIN
[View: _bind]
++ Per Zone Query Statistics ++
--- Statistics Dump --- (1233738626)
stefano.chiesa@wki.it
Posts: 1
Joined: Fri Feb 20, 2009 5:39 am

Re: Bind9-stats-2.0.tar

Post by stefano.chiesa@wki.it »

JeffRoberson wrote:Here is a refreshed tar file with the new scripts and the other files created by Cory Powers. Enjoy!
Hi Jeff, I'm using these scripts since 2006 and I recently installed your updated version for Bind 9.6 (and they work well).
There's a thing I want to ask you. I'm using the "local" version (copying the named.stats file from the dns server to the cacti server and changing his name) but I have 2 dns server and I'm not able to make them work at the same time.

I copied the two statistic files with two different names, I created two different .pl file changing the $STAT_FILE variable, I created two different "bind9-stats.xml" changing the "<script_path>perl |path_cacti|/scripts/bind9-stats.pl</script_path>" statement .....But I always get the statistics from one dns server.

So the simplified question is: on the cacti server you have two statistics files coming from two dns server. How can you get them work?

Sorry for the mess...and thanks in advance.

Stefano.
nstratton
Posts: 1
Joined: Thu Mar 05, 2009 1:43 pm

Having issues with cacti, but not snmpwalk

Post by nstratton »

named 9.6RC2 cacti 0.8.7d SNMP (not local)

Cacti shows debug of:

+ Running data query [10].
+ Found type = '3' [snmp query].
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/bind9-stats-snmp.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ '.1.3.6.1.4.1.2021.55.1'
+ No SNMP data returned
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/bind9-stats-snmp.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/bind9-stats-snmp.xml'
+ Found data query XML file at '/var/www/html/cacti/resource/snmp_queries/bind9-stats-snmp.xml'

However SNMPwalk on the same box shows:

[root@netmon snmp]# snmpwalk -v 1 -c benzOate 10.11.0.5
.1.3.6.1.4.1.2021.55
UCD-SNMP-MIB::ucdavis.55.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.55.1.2 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.55.1.3 = INTEGER: 3
UCD-SNMP-MIB::ucdavis.55.1.4 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.55.2.1 = STRING: "GLOBAL"
UCD-SNMP-MIB::ucdavis.55.2.2 = STRING: "blinkmind.com"
UCD-SNMP-MIB::ucdavis.55.2.3 = STRING: "blinkmind.net"
UCD-SNMP-MIB::ucdavis.55.2.4 = STRING: "72.203.67.in-addr.arpa"
UCD-SNMP-MIB::ucdavis.55.3.1 = INTEGER: 14246
UCD-SNMP-MIB::ucdavis.55.3.2 = INTEGER: 10161
UCD-SNMP-MIB::ucdavis.55.3.3 = INTEGER: 23
UCD-SNMP-MIB::ucdavis.55.3.4 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.4.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.4.2 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.4.3 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.4.4 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.5.1 = INTEGER: 52529
UCD-SNMP-MIB::ucdavis.55.5.2 = INTEGER: 52466
UCD-SNMP-MIB::ucdavis.55.5.3 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.5.4 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.55.6.1 = INTEGER: 253667
UCD-SNMP-MIB::ucdavis.55.6.2 = INTEGER: 253656
UCD-SNMP-MIB::ucdavis.55.6.3 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.6.4 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.7.1 = INTEGER: 4008
UCD-SNMP-MIB::ucdavis.55.7.2 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.7.3 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.7.4 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.8.1 = INTEGER: 21
UCD-SNMP-MIB::ucdavis.55.8.2 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.8.3 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.55.8.4 = INTEGER: 0
rpingar
Cacti User
Posts: 86
Joined: Mon Jun 07, 2004 8:17 am

Post by rpingar »

I am using this script since 3 years ago.

Now my NXDOMAIN skyrocketed i think caused by virueses on my customers' computers.
The problem is that i don't get NXDOMIAN graphed annymore.
No warning no error polling the bind host.

So i think i got some limit about data or graph. in fact i am able to manually collect data through snmp, for exemple:
CD-SNMP-MIB::ucdavis.55.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.55.2.1 = STRING: "GLOBAL"
UCD-SNMP-MIB::ucdavis.55.3.1 = INTEGER: 187816
UCD-SNMP-MIB::ucdavis.55.4.1 = INTEGER: 1517
UCD-SNMP-MIB::ucdavis.55.5.1 = INTEGER: 1944581
UCD-SNMP-MIB::ucdavis.55.6.1 = INTEGER: 3162
UCD-SNMP-MIB::ucdavis.55.7.1 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.55.8.1 = INTEGER: 49945


NXDOMAIN it is about 120K each 5mins.

any help to workaround this?

regards
Ros
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests