21 lines
650 B
Python
Executable file
21 lines
650 B
Python
Executable file
#!/usr/bin/python3
|
|
#
|
|
# Script verifying BIND3 statistics interface work with json
|
|
|
|
import urllib.request
|
|
import json
|
|
import sys
|
|
|
|
url = 'http://localhost:80/json' # use first parameter to override
|
|
timeout = 10 # connection timeout in seconds
|
|
|
|
if len(sys.argv)>1:
|
|
url = sys.argv[1]
|
|
|
|
print("# Reading statistics from URL: {0}".format(url))
|
|
with urllib.request.urlopen(url, timeout=timeout) as req:
|
|
js = json.load(req)
|
|
#print(json.dumps(js, indent=4))
|
|
print('BIND version: ', js['version'])
|
|
print('Socket stats, IPV4 UDP requests: ', js['sockstats']['UDP4Open'])
|
|
print('Name server stats, UDP queries: ', js['nsstats']['QryUDP'])
|