# named.stats is empty



## specialized299 (Feb 17, 2011)

Hello,

I am trying to get some statistics from my DNS server, but each time I run [cmd=]rndc stats[/cmd] the file which should contain stats on the number of DNS queries is empty. My system is running FreeBSD 6.3-RELEASE-p8 and I am running BIND 9.3.4-P1.

I did some research and found some threads indicating that the stats file was might be owned by the wrong user, so I ran *chown* and both files are now owned by the user bind.

I have configured the following in named.conf:


```
options {
        directory       "/etc/namedb";
        pid-file        "/var/run/named/pid";
        dump-file       "/var/dump/named_dump.db";
[B][I]  statistics-file "/var/stats/named.stats";
        zone-statistics yes;[/I][/B]
```

Based on this, the file should be located at /var/stats/named.stats, but this file is 0 Bytes. There is a stats file being created at /var/named/var/stats/named.stats, but it does not seem to contain the data I'm looking for.

Output from /var/named/var/stats/named.stats:


```
+++ Statistics Dump +++ (1257971773)
success 165074
referral 3889542
nxrrset 0
nxdomain 0
recursion 0
failure 0
--- Statistics Dump --- (1257971773)
+++ Statistics Dump +++ (1297895202)
success 1527855
referral 173617239
nxrrset 0
nxdomain 8
recursion 25
failure 25
--- Statistics Dump --- (1297895202)
+++ Statistics Dump +++ (1297895596)
success 1527855
referral 173620364
nxrrset 0
nxdomain 8
recursion 25
failure 25
--- Statistics Dump --- (1297895596)
+++ Statistics Dump +++ (1297895725)
```
The file /var/stats/named.stats should have stats like the ones listed below, but it's empty and the time stamp does not change after I run [cmd=]rndc stats[/cmd] Do I need to upgrade my version of bind to get the statistics Iâ€™m looking for?

Output found from other named.stats files found on the web:


```
+++ Statistics Dump +++ (917839766) Sun Jan 31 22:29:26 1999
       370508  time since boot (secs)
       370508  time since reset (secs)
       130     Unknown query types
       711033  A queries
       35      NS queries
       37      CNAME queries
       40      SOA queries
       2       MB queries
       198963  PTR queries
       26088   MX queries
       1       TXT queries
       20      AAAA queries
       60910   ANY queries
       ++ Name Server Statistics ++
```
Thanks in advance,
M


----------



## DutchDaemon (Feb 17, 2011)

Posting and Editing in the FreeBSD Forums I: proper formatting (this is also in your signup email).


----------



## DutchDaemon (Feb 17, 2011)

If you simply remove that statistics-file line and restart named, running [cmd=]rndc stats[/cmd] will simply dump it in /etc/namedb/named.stats (a.k.a. /var/named/etc/namedb/named.stats).

You should see something like this:


```
# service named restart && rndc stats && cat /var/named/etc/namedb/named.stats
Stopping named.
Starting named.
+++ Statistics Dump +++ (1297972445)
++ Incoming Requests ++
++ Incoming Queries ++
++ Outgoing Queries ++
[View: default]
[View: _bind]
++ Name Server Statistics ++
++ Zone Maintenance Statistics ++
                   1 IPv4 notifies sent
++ Resolver Statistics ++
[Common]
[View: default]
[View: _bind]
++ Cache DB RRsets ++
[View: default]
[View: _bind (Cache: _bind)]
++ Socket I/O Statistics ++
                   2 UDP/IPv4 sockets opened
                   2 TCP/IPv4 sockets opened
                   1 TCP/IPv6 sockets opened
                   1 UDP/IPv4 sockets closed
                   1 TCP/IPv4 connections accepted
++ Per Zone Query Statistics ++
--- Statistics Dump --- (1297972445)
+++ Statistics Dump +++ (1297972571)
++ Incoming Requests ++
++ Incoming Queries ++
++ Outgoing Queries ++
[View: default]
[View: _bind]
++ Name Server Statistics ++
++ Zone Maintenance Statistics ++
                   1 IPv4 notifies sent
++ Resolver Statistics ++
[Common]
[View: default]
[View: _bind]
++ Cache DB RRsets ++
[View: default]
[View: _bind (Cache: _bind)]
++ Socket I/O Statistics ++
                   2 UDP/IPv4 sockets opened
                   2 TCP/IPv4 sockets opened
                   1 TCP/IPv6 sockets opened
                   1 TCP/IPv4 connections accepted
++ Per Zone Query Statistics ++
--- Statistics Dump --- (1297972571)
+++ Statistics Dump +++ (1297972578)
++ Incoming Requests ++
++ Incoming Queries ++
++ Outgoing Queries ++
[View: default]
[View: _bind]
++ Name Server Statistics ++
++ Zone Maintenance Statistics ++
                   1 IPv4 notifies sent
++ Resolver Statistics ++
[Common]
[View: default]
[View: _bind]
++ Cache DB RRsets ++
[View: default]
[View: _bind (Cache: _bind)]
++ Socket I/O Statistics ++
                   2 UDP/IPv4 sockets opened
                   2 TCP/IPv4 sockets opened
                   1 TCP/IPv6 sockets opened
                   1 TCP/IPv4 connections accepted
++ Per Zone Query Statistics ++
--- Statistics Dump --- (1297972578)
```

This is on FreeBSD 8.2-PRERELEASE with BIND 9.7.3.


----------



## quintessence (Feb 23, 2011)

specialized299 said:
			
		

> Do I need to upgrade my version of bind to get the statistics Iâ€™m looking for?



Hello,

No, to get this statistics you have to enable category queries to be logged in some logfile (which is not recommended for heavy loaded DNS server), and then install /usr/ports/net/bindgraph.

For example you can place in the logging directive:


```
channel audit_log {
file "named.log";
print-time yes;
severity debug;
    };
category queries { audit_log; };
```

Also you can set the maximum size of the log filename, if you don't use some external tool for rotating.


----------

