Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cisco_aci/datadog_checks/cisco_aci/aci_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

def make_tenant_metrics():
metrics = {
"healthInst": {"cur": "{}.health"},
"fvOverallHealth": {"healthAvg": "{}.overall_health", "healthLast": "{}.health"},
"fvFltCounter": {"warncountAvg": "{}.fault_counter"},
}
Expand Down
2 changes: 1 addition & 1 deletion cisco_aci/datadog_checks/cisco_aci/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def get_eth_list_for_epg(self, tenant, app, epg):
return self._parse_response(response)

def get_tenant_stats(self, tenant):
path = "/api/mo/uni/tn-{}.json?rsp-subtree-include=stats,no-scoped".format(tenant)
path = "/api/mo/uni/tn-{}.json?rsp-subtree-include=stats,health,no-scoped".format(tenant)
response = self.make_request(path)
# return only the list of stats
return self._parse_response(response)
Expand Down
23 changes: 22 additions & 1 deletion cisco_aci/datadog_checks/cisco_aci/tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def _submit_ten_data(self, tenant):
pass

def submit_raw_obj(self, raw_stats, tags, obj_type):
got_health = False
for s in raw_stats:
name = list(s.keys())[0]
# we only want to collect the 15 minutes metrics.
Expand All @@ -118,9 +119,29 @@ def submit_raw_obj(self, raw_stats, tags, obj_type):
json_attrs = s.get(name, {}).get("attributes", {})
if mval and helpers.check_metric_can_be_zero(cisco_metric, mval, json_attrs):
metrics[dd_metric] = mval

if 'fvOverallHealth' in name:
got_health = True
self.submit_metrics(metrics, tags, instance=self.instance)

if got_health:
return
self.log.debug("No fvOverallHealth reported, looking for healthInst instead")
health_insts = [s for s in raw_stats if list(s.keys())[0] == "healthInst"]
if not health_insts:
self.log.debug("No healthInst reported")
return
s = health_insts[0]
self.log.debug("submitting metrics for: %s", 'healthInst')
metrics = {}

ms = self.tenant_metrics.get(obj_type, {}).get('healthInst', {})
for cisco_metric, dd_metric in ms.items():
mval = s.get('healthInst', {}).get("attributes", {}).get(cisco_metric)
json_attrs = s.get('healthInst', {}).get("attributes", {})
if mval and helpers.check_metric_can_be_zero(cisco_metric, mval, json_attrs):
metrics[dd_metric] = mval
self.submit_metrics(metrics, tags, instance=self.instance)

def collect_events(self, tenant, page=0, page_size=15):
# If there are too many events, it'll break the agent
# stop sending after it reaches page 10 (150 events per tenant)
Expand Down
9 changes: 7 additions & 2 deletions cisco_aci/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@
# d0260e4832537b43b1acb38bcfa58063 - Api.get_tenant_events
'_api_mo_uni_tn_DataDog_json_query_target_subtree_target_subtree_class_fvAp',
# 4efe80304d50330f5ed0f79252ef0a84 - Api.get_apps
'_api_mo_uni_tn_DataDog_json_rsp_subtree_include_stats_no_scoped',
# c8e9a0dbceac67fb1149684f7fc7772c - Api.get_tenant_stats
'_api_mo_uni_tn_DataDog_json_rsp_subtree_include_stats_health_no_scoped',
# 07f9ef7474c39eef33e9ddfd269d54fb - Api.get_tenant_stats
'_api_mo_uni_tn_DataDogAlt_json_rsp_subtree_include_stats_health_no_scoped',
# cd84d80314a78b27c72f287322f30b68 - Api.get_tenant_stats
'_api_node_class_lldpAdjEp_json',
# f3713df3a586908a3a11f4c356153519 - Api.get_lldp_adj_eps
'_api_node_class_cdpAdjEp_json',
Expand Down Expand Up @@ -230,6 +232,9 @@ def make_request(self, path):
mock_path = mock_path.replace('[', '_')
mock_path = mock_path.replace(']', '_')
mock_path = mock_path.replace('|', '_')
if mock_path not in FIXTURE_LIST_FILE_MAP:
log.debug("Skipping %s - no fixture file found", path)
return {"imdata": []}
mock_path = FIXTURE_LIST_FILE_MAP[mock_path]
for p in self.fixture_dirs:
path = os.path.join(p, mock_path)
Expand Down
Loading
Loading