BIND9 statistics-server: JSON?
Jan-Piet Mens
jpmens.dns at gmail.com
Fri Feb 15 05:57:10 UTC 2013
As a fan of BIND's statistics-server I was tempted to see if I could
reduce the size of the data (XML) named produces by adding an option to
produce JSON. The patch [1] (which is terribly quick and dirty) does that.
[1] https://gist.github.com/jpmens/4958763
Accessing the URI /json on named would produce something like this:
{
"views": {
"_default": [
{
"name": "0.IN-ADDR.ARPA",
"class": "IN",
"serial": 0
},
{
"name": "B.E.F.IP6.ARPA",
"class": "IN",
"serial": 0
},
[...]
{
"name": "ww.mens.de",
"class": "IN",
"serial": 201211565
}
],
"_bind": [
{
"name": "authors.bind",
"class": "CH",
"serial": 0
},
[...]
]
}
}
Which of course is trivial to parse, with say,
#!/usr/bin/env python
import sys, json urllib2
BINDURI = 'http://127.0.0.1:8053/json'
f = urllib2.urlopen(BINDURI)
# print f.headers
doc = json.loads(f.read())
views = doc['views']
for viewname, zonelist in views.iteritems():
print viewname
for zone in zonelist:
print "\t%s %-40s %s" % (zone['class'], zone['name'], zone['serial'])
which in turn makes this:
_default
IN 0.IN-ADDR.ARPA 0
IN B.E.F.IP6.ARPA 0
IN ww.mens.de 201211565
[...]
_bind
CH authors.bind 0
[...]
I haven't yet conducted tests as to which is actually faster to
produce/transport/consume, but I _suspect_ it's JSON. :)
If I cleaned this up appropriately and attempted to add some (all?) of
the counters (I'm mostly interested in the list of zones which is why I
started with that) would there be a chance of ISC adding this to stock
BIND9? Even better: would ISC take on the work of doing it? ;-)
Regards,
-JP
More information about the bind-users
mailing list