def main(): parser = argparse.ArgumentParser( description='Parse BIND XML stats on demand.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--host', help='hostname to query for DNS statistics') parser.add_argument('--port', type=int, default=8053, help='BIND statistics port to query') parser.add_argument('--xml', help='path to file which contains BIND XML.') args = parser.parse_args() if args.xml: mybind = reader.BindXmlReader(xml_path=args.xml) else: mybind = reader.BindXmlReader(host=args.host, port=args.port) mybind.get_stats() print("memory stats: %s" % mybind.stats.memory_stats) print("query stats: %s" % mybind.stats.query_stats) print("zone list: %s" % mybind.stats.zone_stats) print("done")
def list_zones(self): """List the DNS zones and attributes. TODO: Parse these XML more intelligently. Grab the view name. Any other data available? Returns: List of Dicts { String view_name, String zone_name, String zone_class, String zone_serial } """ zone_data = bindreader.BindXmlReader(host=self.hostname, port=self.statistics_port) zone_data.get_stats() return zone_data
def list_zones(self): zones = reader.BindXmlReader( host=self.ip_address, port=self.statistics_port) zones.get_stats() for name, view in zones.stats.zone_stats.items(): for view_name, view_info in view.items(): if name.lower().endswith('arpa') or\ 'localhost' in name.lower(): continue zone_obj, _ = Zone.objects.get_or_create(zone_name=name) zone_obj.server = self zone_obj.view_name = view_name zone_obj.zone_serial = view_info['serial'] zone_obj.save()
def list_zones(self): """List the DNS zones and attributes. TODO: Parse these XML more intelligently. Grab the view name. Any other data available? Returns: List of Dicts { String view_name, String zone_name, String zone_class, String zone_serial } """ if self.server_type == "BIND": # TODO: just return stats from get_stats call. This is probably not used # anywhere else. zone_data = bindreader.BindXmlReader(host=self.hostname, port=self.control_port) zone_data.get_stats() return zone_data elif self.server_type == "NSD": zone_data = nsd.NSDServer(hostname=self.hostname, control_port=self.control_port) zone_dict = zone_data.get_zone_list() return zone_dict
def setUp(self): self.xml_obj = reader.BindXmlReader( xml_filepath='testdata/bindxml-v3_3.xml') self.xml_obj.get_stats()