diff --git a/test/data/check-snmp-agent-configs.py b/test/data/check-snmp-agent-configs.py index e91061e801269cc03d75f955a1da27fc956296e6..77304c0636a22ce30db3eca9558ed41dea5e1a43 100644 --- a/test/data/check-snmp-agent-configs.py +++ b/test/data/check-snmp-agent-configs.py @@ -15,6 +15,7 @@ COLLECTORS = [ 'test-noc-alarms03.geant.org' ] + def v4_address(hostname): for a in socket.getaddrinfo(hostname, None): (family, type, proto, canonname, sockaddr) = a @@ -25,13 +26,13 @@ def v4_address(hostname): return sockaddr[0] assert False, 'not resolveable' + ADDRESS = dict([(c, v4_address(c)) for c in COLLECTORS]) with open('config-sentinel.json') as f: params = config.load(f) - def agent_addresses(netconf_string): doc = etree.fromstring(netconf_string) return doc.xpath('//configuration/snmp/trap-group/targets/name/text()') @@ -42,9 +43,11 @@ print(','.join(columns)) columns = [''] + [ADDRESS[c] for c in COLLECTORS] print(','.join(columns)) + def _c(b): return '+' if b else 'MISSING' + r = get_current_redis(params) for k in r.scan_iter('netconf:*'): k = k.decode('utf-8') @@ -57,8 +60,3 @@ for k in r.scan_iter('netconf:*'): columns += [_c(ADDRESS[c] in agents) for c in COLLECTORS] print(','.join(columns)) - # # print(k) - # # print(etree.pretty_print(netconf_doc)) - # break - -