def test_no_tenant(aggregator): api = ApiMock() check = CiscoACICheck(common.CHECK_NAME, {}, {}) api._refresh_sessions = False check._api_cache[hash_mutable(hash_mutable({}))] = api tenant = Tenant(check, api, {}, None) tenant.collect() assert len(aggregator._metrics.items()) == 0
def check(self, _): self._instance_state = self._instance_states[hash_mutable( self.instance)] data = self.get_data() self._collect_version(data) self._create_metrics(data) if self._sync_gateway_url: self._collect_sync_gateway_metrics()
def test_should_zk(): check = KafkaCheck('kafka_consumer', {}, {}) # Kafka Consumer Offsets set to True and we have a zk_connect_str that hasn't been run yet assert check._should_zk([ZK_CONNECT_STR, ZK_CONNECT_STR], 10, True) is True # Kafka Consumer Offsets is set to False, should immediately ZK assert check._should_zk(ZK_CONNECT_STR, 10, False) is True # Last time we checked ZK_CONNECT_STR was less than interval ago, shouldn't ZK zk_connect_hash = hash_mutable(ZK_CONNECT_STR) check._zk_last_ts[zk_connect_hash] = time.time() assert check._should_zk(ZK_CONNECT_STR, 100, True) is False
def test_cisco(aggregator): cisco_aci_check = CiscoACICheck(common.CHECK_NAME, {}, [common.CONFIG]) api = Api(common.ACI_URLS, cisco_aci_check.http, common.USERNAME, password=common.PASSWORD, log=cisco_aci_check.log) api.wrapper_factory = common.FakeSessionWrapper cisco_aci_check._api_cache[hash_mutable(common.CONFIG)] = api cisco_aci_check.check({})
def _should_zk(self, zk_hosts_ports, interval, kafka_collect=False): if not kafka_collect or not interval: return True zk_hosts_ports_hash = hash_mutable(zk_hosts_ports) now = time() last = self._zk_last_ts.get(zk_hosts_ports_hash, 0) should_zk = False if now - last >= interval: self._zk_last_ts[zk_hosts_ports_hash] = last should_zk = True return should_zk
def check(self, instance): normalize_metrics = is_affirmative(instance.get("normalize_metrics", False)) instance_key = hash_mutable(instance) if instance_key in self.instance_cache: config = self.instance_cache[instance_key]["config"] profiler = self.instance_cache[instance_key]["profiler"] else: config = FilebeatCheckInstanceConfig(instance) profiler = FilebeatCheckHttpProfiler(config) self.instance_cache[instance_key] = {"config": config, "profiler": profiler} self._process_registry(config) self._gather_http_profiler_metrics(config, profiler, normalize_metrics)
def check(self, instance): instance_key = hash_mutable(instance) if instance_key in self.instance_cache: config = self.instance_cache[instance_key]["config"] profiler = self.instance_cache[instance_key]["profiler"] else: config = FilebeatCheckInstanceConfig(instance) profiler = FilebeatCheckHttpProfiler(config) self.instance_cache[instance_key] = { "config": config, "profiler": profiler } self._process_registry(config) self._gather_http_profiler_metrics(config, profiler)
def check(self, instance): instance_state = self._instance_states[hash_mutable(instance)] server = instance.get('server', None) if server is None: raise Exception("The server must be specified") tags = instance.get('tags', []) # Clean up tags in case there was a None entry in the instance # e.g. if the yaml contains tags: but no actual tags if tags is None: tags = [] else: tags = list(set(tags)) tags.append('instance:{}'.format(server)) data = self.get_data(server, instance) self._collect_version(data) self._create_metrics(data, instance_state, server, tags=list(set(tags)))
def check(self, instance): # Instance state is mutable, any changes to it will be reflected in self._instance_states instance_state = self._instance_states[hash_mutable(instance)] self._check_for_leader_change(instance, instance_state) peers = self.get_peers_in_cluster(instance) main_tags = [] agent_dc = self._get_agent_datacenter(instance, instance_state) if agent_dc is not None: main_tags.append('consul_datacenter:{}'.format(agent_dc)) for tag in instance.get('tags', []): main_tags.append(tag) single_node_install = is_affirmative( instance.get('single_node_install', False)) if not self._is_instance_leader(instance, instance_state): self.gauge("consul.peers", len(peers), tags=main_tags + ["mode:follower"]) if not single_node_install: self.log.debug( "This consul agent is not the cluster leader. " "Skipping service and catalog checks for this instance") return else: self.gauge("consul.peers", len(peers), tags=main_tags + ["mode:leader"]) service_check_tags = main_tags + [ 'consul_url:{}'.format(instance.get('url')) ] perform_catalog_checks = is_affirmative( instance.get('catalog_checks', self.init_config.get('catalog_checks'))) perform_network_latency_checks = is_affirmative( instance.get('network_latency_checks', self.init_config.get('network_latency_checks'))) try: # Make service checks from health checks for all services in catalog health_state = self.consul_request(instance, '/v1/health/state/any') sc = {} # compute the highest status level (OK < WARNING < CRITICAL) a a check among all the nodes is running on. for check in health_state: sc_id = '{}/{}/{}'.format(check['CheckID'], check.get('ServiceID', ''), check.get('ServiceName', '')) status = self.STATUS_SC.get(check['Status']) if status is None: status = AgentCheck.UNKNOWN if sc_id not in sc: tags = ["check:{}".format(check["CheckID"])] if check["ServiceName"]: tags.append("service:{}".format(check["ServiceName"])) if check["ServiceID"]: tags.append("consul_service_id:{}".format( check["ServiceID"])) sc[sc_id] = {'status': status, 'tags': tags} elif self.STATUS_SEVERITY[status] > self.STATUS_SEVERITY[ sc[sc_id]['status']]: sc[sc_id]['status'] = status for s in itervalues(sc): self.service_check(self.HEALTH_CHECK, s['status'], tags=main_tags + s['tags']) except Exception as e: self.log.error(e) self.service_check(self.CONSUL_CHECK, AgentCheck.CRITICAL, tags=service_check_tags) else: self.service_check(self.CONSUL_CHECK, AgentCheck.OK, tags=service_check_tags) if perform_catalog_checks: # Collect node by service, and service by node counts for a whitelist of services services = self.get_services_in_cluster(instance) service_whitelist = instance.get( 'service_whitelist', self.init_config.get('service_whitelist', [])) max_services = instance.get( 'max_services', self.init_config.get('max_services', self.MAX_SERVICES)) self.count_all_nodes(instance, main_tags) services = self._cull_services_list(services, service_whitelist, max_services) # {node_id: {"up: 0, "passing": 0, "warning": 0, "critical": 0} nodes_to_service_status = defaultdict(lambda: defaultdict(int)) for service in services: # For every service in the cluster, # Gauge the following: # `consul.catalog.nodes_up` : # of Nodes registered with that service # `consul.catalog.nodes_passing` : # of Nodes with service status `passing` from those registered # `consul.catalog.nodes_warning` : # of Nodes with service status `warning` from those registered # `consul.catalog.nodes_critical` : # of Nodes with service status `critical` from those registered service_tags = self._get_service_tags(service, services[service]) nodes_with_service = self.get_nodes_with_service( instance, service) # {'up': 0, 'passing': 0, 'warning': 0, 'critical': 0} node_status = defaultdict(int) for node in nodes_with_service: # The node_id is n['Node']['Node'] node_id = node.get('Node', {}).get("Node") # An additional service is registered on this node. Bump up the counter nodes_to_service_status[node_id]["up"] += 1 # If there is no Check for the node then Consul and dd-agent consider it up if 'Checks' not in node: node_status['passing'] += 1 node_status['up'] += 1 else: found_critical = False found_warning = False found_serf_health = False for check in node['Checks']: if check['CheckID'] == 'serfHealth': found_serf_health = True # For backwards compatibility, the "up" node_status is computed # based on the total # of nodes 'running' as part of the service. # If the serfHealth is `critical` it means the Consul agent isn't even responding, # and we don't register the node as `up` if check['Status'] != 'critical': node_status["up"] += 1 continue if check['Status'] == 'critical': found_critical = True break elif check['Status'] == 'warning': found_warning = True # Keep looping in case there is a critical status # Increment the counters based on what was found in Checks # `critical` checks override `warning`s, and if neither are found, # register the node as `passing` if found_critical: node_status['critical'] += 1 nodes_to_service_status[node_id]["critical"] += 1 elif found_warning: node_status['warning'] += 1 nodes_to_service_status[node_id]["warning"] += 1 else: if not found_serf_health: # We have not found a serfHealth check for this node, which is unexpected # If we get here assume this node's status is "up", since we register it as 'passing' node_status['up'] += 1 node_status['passing'] += 1 nodes_to_service_status[node_id]["passing"] += 1 for status_key in self.STATUS_SC: status_value = node_status[status_key] self.gauge( '{}.nodes_{}'.format(self.CONSUL_CATALOG_CHECK, status_key), status_value, tags=main_tags + service_tags, ) for node, service_status in iteritems(nodes_to_service_status): # For every node discovered for whitelisted services, gauge the following: # `consul.catalog.services_up` : Total services registered on node # `consul.catalog.services_passing` : Total passing services on node # `consul.catalog.services_warning` : Total warning services on node # `consul.catalog.services_critical` : Total critical services on node node_tags = ['consul_node_id:{}'.format(node)] self.gauge('{}.services_up'.format(self.CONSUL_CATALOG_CHECK), len(services), tags=main_tags + node_tags) for status_key in self.STATUS_SC: status_value = service_status[status_key] self.gauge( '{}.services_{}'.format(self.CONSUL_CATALOG_CHECK, status_key), status_value, tags=main_tags + node_tags, ) if perform_network_latency_checks: self.check_network_latency(instance, agent_dc, main_tags)
def check(self, _): aci_url = self.instance.get('aci_url') aci_urls = self.instance.get('aci_urls', []) if aci_url: aci_urls.append(aci_url) if not aci_urls: raise ConfigurationError( "The Cisco ACI check requires at least one url") username = self.instance['username'] pwd = self.instance.get('pwd') instance_hash = hash_mutable(self.instance) appcenter = _is_affirmative(self.instance.get('appcenter')) cert_key = self.instance.get('cert_key') if not cert_key and self.instance.get('cert_key_path'): with open(self.instance.get('cert_key_path'), 'rb') as f: cert_key = f.read() cert_name = self.instance.get('cert_name') if not cert_name: cert_name = username cert_key_password = self.instance.get('cert_key_password') if instance_hash in self._api_cache: api = self._api_cache.get(instance_hash) else: api = Api( aci_urls, self.http, username, password=pwd, cert_name=cert_name, cert_key=cert_key, log=self.log, appcenter=appcenter, cert_key_password=cert_key_password, ) self._api_cache[instance_hash] = api service_check_tags = [] for url in aci_urls: service_check_tags.append("url:{}".format(url)) service_check_tags.extend(self.check_tags) service_check_tags.extend(self.instance.get('tags', [])) try: api.login() except Exception as e: self.log.error("Cannot login to the Cisco ACI: %s", e) self.service_check( SERVICE_CHECK_NAME, AgentCheck.CRITICAL, message="aci login returned a status of {}".format(e), tags=service_check_tags, ) raise self.tagger.api = api try: tenant = Tenant(self, api, self.instance, instance_hash) tenant.collect() except Exception as e: self.log.error('tenant collection failed: %s', e) self.service_check( SERVICE_CHECK_NAME, AgentCheck.CRITICAL, message="aci tenant operations failed, returning a status of {}" .format(e), tags=service_check_tags, ) api.close() raise try: fabric = Fabric(self, api, self.instance) fabric.collect() except Exception as e: self.log.error('fabric collection failed: %s', e) self.service_check( SERVICE_CHECK_NAME, AgentCheck.CRITICAL, message="aci fabric operations failed, returning a status of {}" .format(e), tags=service_check_tags, ) api.close() raise try: capacity = Capacity(api, self.instance, check_tags=self.check_tags, gauge=self.gauge, log=self.log) capacity.collect() except Exception as e: self.log.error('capacity collection failed: %s', e) self.service_check( SERVICE_CHECK_NAME, AgentCheck.CRITICAL, message= "aci capacity operations failed, returning a status of {}". format(e), tags=service_check_tags, ) api.close() raise self.service_check(SERVICE_CHECK_NAME, AgentCheck.OK, tags=service_check_tags) self.set_external_tags(self.get_external_host_tags()) api.close()
def _tenant_mapper(self, edpt): tags = [] if not edpt or type(edpt) is not dict: return tags application_meta = [] application_meta_map = self._edpt_tags_map(edpt) for k, v in iteritems(application_meta_map): application_meta.append(k + ":" + v) tenant_name = application_meta_map.get("tenant") app_name = application_meta_map.get("application") epg_name = application_meta_map.get("endpoint_group") # adding meta tags endpoint_meta = [] endpoint_meta_map = self._get_epg_meta_tags_map( tenant_name, app_name, epg_name) for k, v in iteritems(endpoint_meta_map): endpoint_meta.append(k + ":" + v) # adding application tags endpoint_meta += application_meta context_hash = hash_mutable(endpoint_meta) eth_meta = [] if self.tenant_tags.get(context_hash): eth_meta = self.tenant_tags.get(context_hash) else: try: # adding eth and node tags eth_list = self.api.get_eth_list_for_epg( tenant_name, app_name, epg_name) for eth in eth_list: eth_attrs = eth.get('fvRsCEpToPathEp', {}).get('attributes', {}) port = re.search(r'/pathep-\[(.+?)\]', eth_attrs.get('tDn', '')) if not port: continue eth_tag = 'port:' + port.group(1) if eth_tag not in eth_meta: eth_meta.append(eth_tag) node = re.search('/paths-(.+?)/', eth_attrs.get('tDn', '')) if not node: continue eth_node = 'node_id:' + node.group(1) if eth_node not in eth_meta: eth_meta.append(eth_node) # populating the map for eth-app mapping tenant_fabric_key = node.group(1) + ":" + port.group(1) if tenant_fabric_key not in self.tenant_farbic_mapper: self.tenant_farbic_mapper[ tenant_fabric_key] = application_meta else: self.tenant_farbic_mapper[tenant_fabric_key].extend( application_meta) self.tenant_farbic_mapper[tenant_fabric_key] = list( set(self.tenant_farbic_mapper[tenant_fabric_key])) except (exceptions.APIConnectionException, exceptions.APIParsingException): # the exception will already be logged, just pass it over here pass tags = tags + endpoint_meta + eth_meta if len(eth_meta) > 0: self.log.debug('adding eth level tags: %s', eth_meta) return tags
def test_tenant_mocked(aggregator): check = CiscoACICheck(common.CHECK_NAME, {}, {}) api = Api(common.ACI_URLS, check.http, common.USERNAME, password=common.PASSWORD, log=check.log) api.wrapper_factory = common.FakeTenantSessionWrapper check._api_cache[hash_mutable(common.CONFIG_WITH_TAGS)] = api check.check(common.CONFIG_WITH_TAGS) tags = ['project:cisco_aci', 'tenant:DataDog'] metric_name = 'cisco_aci.tenant.ingress_bytes.multicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.egress_bytes.multicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_pkts.multicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.health' aggregator.assert_metric(metric_name, value=99.0, tags=tags, hostname='') metric_name = 'cisco_aci.tenant.overall_health' aggregator.assert_metric(metric_name, value=99.0, tags=tags, hostname='') metric_name = 'cisco_aci.tenant.egress_pkts.unicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.egress_pkts.unicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.application.fault_counter' aggregator.assert_metric(metric_name, value=0.0, tags=['application:DtDg-AP1-EcommerceApp'] + tags, hostname='') aggregator.assert_metric(metric_name, value=0.0, tags=['application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric(metric_name, value=0.0, tags=['application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.fault_counter' aggregator.assert_metric(metric_name, value=4.0, tags=tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_bytes.flood.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_pkts.unicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.egress_bytes.unicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.egress_pkts.multicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_pkts.flood.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.egress_bytes.unicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.egress_bytes.multicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_bytes.unicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_pkts.drop.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.capacity.apic.fabric_node.utilized' aggregator.assert_metric(metric_name, value=0.0, tags=['project:cisco_aci', 'cisco'], hostname='') metric_name = 'cisco_aci.tenant.ingress_pkts.multicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.egress_pkts.multicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_bytes.drop.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_bytes.unicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_bytes.multicast.cum' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') metric_name = 'cisco_aci.tenant.ingress_pkts.unicast.rate' aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Pay', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-MiscAppVMs', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Inv', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Ord', 'application:DtDg-AP1-EcommerceApp'] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Ecomm', 'application:DtDg-AP1-EcommerceApp' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti2', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=[ 'endpoint_group:DtDg-Jetty_Controller', 'application:DtDg-AP2-Jeti' ] + tags, hostname='', ) aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:DtDg-Jeti1', 'application:DtDg-AP2-Jeti'] + tags, hostname='') aggregator.assert_metric( metric_name, value=0.0, tags=['endpoint_group:Test-EPG', 'application:DtDg-test-AP'] + tags, hostname='') # Assert coverage for this check on this instance aggregator.assert_all_metrics_covered()
def test_hash_mutable(self, value): h = hash_mutable(value) assert isinstance(h, int)
def check(self, instance): # Connect to the WMI provider host = instance.get('host', "localhost") username = instance.get('username', "") password = instance.get('password', "") instance_tags = instance.get('tags', []) notify = instance.get('notify', []) event_priority = instance.get('event_priority', self._default_event_priority) if (event_priority.lower() != 'normal') and (event_priority.lower() != 'low'): event_priority = 'normal' user = instance.get('user') ltypes = instance.get('type', []) source_names = instance.get('source_name', []) log_files = instance.get('log_file', []) event_ids = instance.get('event_id', []) event_format = instance.get('event_format') message_filters = instance.get('message_filters', []) if not (source_names or event_ids or message_filters or log_files or user or ltypes): raise ConfigurationError( 'At least one of the following filters must be set: ' 'source_name, event_id, message_filters, log_file, user, type' ) instance_hash = hash_mutable(instance) instance_key = self._get_instance_key(host, self.NAMESPACE, self.EVENT_CLASS, instance_hash) # Store the last timestamp by instance if instance_key not in self.last_ts: # If system boot was withing 600s of dd agent start then use boottime as last_ts if uptime() <= 600: self.last_ts[instance_key] = datetime.utcnow() - timedelta(seconds=uptime()) else: self.last_ts[instance_key] = datetime.utcnow() return # Event properties event_properties = list(self.EVENT_PROPERTIES) if event_format is not None: event_properties.extend(list(set(self.EXTRA_EVENT_PROPERTIES) & set(event_format))) else: event_properties.extend(self.EXTRA_EVENT_PROPERTIES) # Event filters query = {} filters = [] last_ts = self.last_ts[instance_key] query['TimeGenerated'] = ('>=', self._dt_to_wmi(last_ts)) if user: query['User'] = ('=', user) if ltypes: query['Type'] = [] for ltype in ltypes: query['Type'].append(('=', ltype)) if source_names: query['SourceName'] = [] for source_name in source_names: query['SourceName'].append(('=', source_name)) if log_files: query['LogFile'] = [] for log_file in log_files: query['LogFile'].append(('=', log_file)) if event_ids: query['EventCode'] = [] for event_id in event_ids: query['EventCode'].append(('=', event_id)) if message_filters: query['NOT Message'] = [] query['Message'] = [] for filt in message_filters: if filt[0] == '-': query['NOT Message'].append(('LIKE', filt[1:])) else: query['Message'].append(('LIKE', filt)) filters.append(query) wmi_sampler = self._get_wmi_sampler( instance_key, self.EVENT_CLASS, event_properties, filters=filters, host=host, namespace=self.NAMESPACE, username=username, password=password, and_props=['Message'], ) wmi_sampler.reset_filter(new_filters=filters) try: wmi_sampler.sample() except TimeoutException: self.log.warning( u"[Win32EventLog] WMI query timed out." u" class={wmi_class} - properties={wmi_properties} -" u" filters={filters} - tags={tags}".format( wmi_class=self.EVENT_CLASS, wmi_properties=event_properties, filters=filters, tags=instance_tags ) ) else: for ev in wmi_sampler: # for local events we dont need to specify a hostname hostname = None if (host == "localhost" or host == ".") else host log_ev = LogEvent( ev, self.log, hostname, instance_tags, notify, self._tag_event_id, event_format, event_priority ) # Since WQL only compares on the date and NOT the time, we have to # do a secondary check to make sure events are after the last # timestamp if log_ev.is_after(last_ts): self.event(log_ev.to_event_dict()) else: self.log.debug('Skipping event after %s. ts=%s' % (last_ts, log_ev.timestamp)) # Update the last time checked self.last_ts[instance_key] = datetime.utcnow()
def test_hash_mutable_order_irrelevant(self, left, right): assert hash_mutable(left) == hash_mutable(right)
def test_hash_mutable(self, value): h = hash_mutable(value) # Must not fail. assert isinstance(h, int)
def test_hash_mutable_commutative(self, left, right): """ hash_mutable() is expected to return the same hash regardless of the order of items in the container. """ assert hash_mutable(left) == hash_mutable(right)
def test_hash_mutable_unsupported_mixed_type(self, value): """ Hashing mixed type containers is not supported, mostly because we haven't needed to add support for it yet. """ with pytest.raises(TypeError): hash_mutable(value)
def test_hash_mutable_none_is_not_just_falsy(self, value): """ None shouldn't be treated as any other false-y value when computing hashes. """ assert hash_mutable(['test', None]) != hash_mutable(['test', value])
def check(self, instance): """ Fetch WMI metrics. """ # Connection information host = instance.get('host', "localhost") namespace = instance.get('namespace', "root\\cimv2") provider = instance.get('provider') username = instance.get('username', "") password = instance.get('password', "") # WMI instance wmi_class = instance.get('class') metrics = instance.get('metrics') filters = instance.get('filters') tag_by = instance.get('tag_by', "") tag_queries = instance.get('tag_queries', []) constant_tags = instance.get('constant_tags') custom_tags = instance.get('tags', []) if constant_tags is None: constant_tags = list(custom_tags) else: constant_tags.extend(custom_tags) self.log.warning( "`constant_tags` is being deprecated, please use `tags`") # Create or retrieve an existing WMISampler instance_hash = hash_mutable(instance) instance_key = self._get_instance_key(host, namespace, wmi_class, instance_hash) metric_name_and_type_by_property, properties = self._get_wmi_properties( instance_key, metrics, tag_queries) wmi_sampler = self._get_running_wmi_sampler( instance_key, wmi_class, properties, tag_by=tag_by, filters=filters, host=host, namespace=namespace, provider=provider, username=username, password=password, ) # Sample, extract & submit metrics try: wmi_sampler.sample() metrics = self._extract_metrics(wmi_sampler, tag_by, tag_queries, constant_tags) except TimeoutException: self.log.warning( "WMI query timed out. class=%s - properties=%s - filters=%s - tag_queries=%s", wmi_class, properties, filters, tag_queries, ) else: self._submit_metrics(metrics, metric_name_and_type_by_property)
def test_capacity_mocked(aggregator): check = CiscoACICheck(common.CHECK_NAME, {}, {}) api = Api(common.ACI_URLS, check.http, common.USERNAME, password=common.PASSWORD, log=check.log) api.wrapper_factory = common.FakeCapacitySessionWrapper check._api_cache[hash_mutable(common.CONFIG_WITH_TAGS)] = api check.check(common.CONFIG_WITH_TAGS) tags = ['cisco', 'project:cisco_aci'] aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.utilized', value=44.0, tags=['fabric_pod_id:1', 'node_id:101'] + tags, hostname='pod-1-node-101', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.utilized', value=1.0, tags=['fabric_pod_id:1', 'node_id:201'] + tags, hostname='pod-1-node-201', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.utilized', value=1.0, tags=['fabric_pod_id:1', 'node_id:202'] + tags, hostname='pod-1-node-202', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.utilized', value=34.0, tags=['fabric_pod_id:1', 'node_id:102'] + tags, hostname='pod-1-node-102', ) aggregator.assert_metric('cisco_aci.capacity.apic.endpoint_group.utilized', value=205.0, tags=tags, hostname='') aggregator.assert_metric( 'cisco_aci.capacity.apic.private_network.utilized', value=85.0, tags=tags, hostname='') aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:101'] + tags, hostname='pod-1-node-101', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:201'] + tags, hostname='pod-1-node-201', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:202'] + tags, hostname='pod-1-node-202', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.bridge_domain.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:102'] + tags, hostname='pod-1-node-102', ) aggregator.assert_metric('cisco_aci.capacity.apic.tenant.utilized', value=90.0, tags=tags, hostname='') aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.utilized', value=94.0, tags=['fabric_pod_id:1', 'node_id:101'] + tags, hostname='pod-1-node-101', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.utilized', value=0.0, tags=['fabric_pod_id:1', 'node_id:201'] + tags, hostname='pod-1-node-201', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.utilized', value=0.0, tags=['fabric_pod_id:1', 'node_id:202'] + tags, hostname='pod-1-node-202', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.utilized', value=78.0, tags=['fabric_pod_id:1', 'node_id:102'] + tags, hostname='pod-1-node-102', ) aggregator.assert_metric('cisco_aci.capacity.apic.endpoint_group.limit', value=15000.0, tags=tags, hostname='') aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:101'] + tags, hostname='pod-1-node-101', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:201'] + tags, hostname='pod-1-node-201', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:202'] + tags, hostname='pod-1-node-202', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.endpoint_group.limit', value=3500.0, tags=['fabric_pod_id:1', 'node_id:102'] + tags, hostname='pod-1-node-102', ) aggregator.assert_metric('cisco_aci.capacity.apic.endpoint.limit', value=180000.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.endpoint.utilized', value=76.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.bridge_domain.utilized', value=154.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.vmware_domain.limit', value=5.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.private_network.limit', value=3000.0, tags=tags, hostname='') aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.utilized', value=32.0, tags=['fabric_pod_id:1', 'node_id:101'] + tags, hostname='pod-1-node-101', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.utilized', value=4.0, tags=['fabric_pod_id:1', 'node_id:201'] + tags, hostname='pod-1-node-201', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.utilized', value=4.0, tags=['fabric_pod_id:1', 'node_id:202'] + tags, hostname='pod-1-node-202', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.utilized', value=27.0, tags=['fabric_pod_id:1', 'node_id:102'] + tags, hostname='pod-1-node-102', ) aggregator.assert_metric('cisco_aci.capacity.apic.contract.limit', value=1000.0, tags=tags, hostname='') aggregator.assert_metric( 'cisco_aci.capacity.apic.azure_domain.endpoint_group.limit', value=9000.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.fabric_node.limit', value=200.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.bridge_domain.limit', value=15000.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.fabric_node.utilized', value=2.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.tenant.limit', value=3000.0, tags=tags, hostname='') aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.limit', value=800.0, tags=['fabric_pod_id:1', 'node_id:101'] + tags, hostname='pod-1-node-101', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.limit', value=800.0, tags=['fabric_pod_id:1', 'node_id:201'] + tags, hostname='pod-1-node-201', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.limit', value=800.0, tags=['fabric_pod_id:1', 'node_id:202'] + tags, hostname='pod-1-node-202', ) aggregator.assert_metric( 'cisco_aci.capacity.leaf.vrf.limit', value=800.0, tags=['fabric_pod_id:1', 'node_id:102'] + tags, hostname='pod-1-node-102', ) aggregator.assert_metric( 'cisco_aci.capacity.apic.vmware_domain.endpoint_group.limit', value=15000.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.azure_domain.limit', value=5.0, tags=tags, hostname='') aggregator.assert_metric('cisco_aci.capacity.apic.service_graph.limit', value=600.0, tags=tags, hostname='')
def test_tenant_mapper(): tags = CiscoTags() api1 = ApiMock1() tags.api = api1 assert tags._tenant_mapper(None) == [] assert tags._tenant_mapper("") == [] assert tags._tenant_mapper("aaa") == [] assert tags._tenant_mapper([]) == [] assert tags._tenant_mapper(["aaa"]) == [] assert tags._tenant_mapper({}) == [] assert tags._tenant_mapper({"aaa": "aaa"}) == [] assert all([ a == b for a, b in zip( sorted( tags._tenant_mapper( {"attributes": { "name": "aaa", "dn": "a/tn-bbb/ap-ccc/a" }})), sorted(['tenant:bbb', 'endpoint_group:aaa', 'application:ccc']), ) ]) api2 = ApiMock2() tags.api = api2 assert all([ a == b for a, b in zip( sorted( tags._tenant_mapper( {"attributes": { "name": "aaa", "dn": "a/tn-bbb/ap-ccc/a" }})), sorted([ 'tenant:bbb', 'application:ccc', 'endpoint_group:aaa', "ip:ddd", "mac:eee", "encap:fff" ]), ) ]) context_hash = hash_mutable([ 'tenant:bbb', 'application:ccc', 'endpoint_group:aaa', "ip:ddd", "mac:eee", "encap:fff" ]) api3 = ApiMock3() tags.api = api3 tags.tenant_tags = {context_hash: ["test:ggg"]} assert all([ a == b for a, b in zip( sorted( tags._tenant_mapper( {"attributes": { "name": "aaa", "dn": "a/tn-bbb/ap-ccc/a" }})), sorted([ 'tenant:bbb', 'application:ccc', 'endpoint_group:aaa', "ip:ddd", "mac:eee", "encap:fff", "test:ggg", ]), ) ]) assert tags.tenant_farbic_mapper == {} api3 = ApiMock3() tags.api = api3 tags.tenant_tags = {} assert all([ a == b for a, b in zip( sorted( tags._tenant_mapper( {"attributes": { "name": "aaa", "dn": "a/tn-bbb/ap-ccc/a" }})), sorted([ 'ip:ddd', 'mac:eee', 'encap:fff', 'endpoint_group:aaa', 'application:ccc', 'tenant:bbb', 'port:bbb', 'port:ccc', 'port:ddd', 'port:kkk', 'node_id:[jjj]', ]), ) ]) assert all([ a == b for a, b in zip( sorted(tags.tenant_farbic_mapper.get('[jjj]:kkk', [])), sorted(['application:ccc', 'endpoint_group:aaa', 'tenant:bbb']), ) ])