4
4
5
5
from six import iteritems
6
6
7
+ from datadog_checks .base .utils .serialization import json
8
+ from datadog_checks .cisco_aci .models import DeviceMetadata , Node
7
9
from . import aci_metrics , exceptions , helpers
8
10
9
11
@@ -25,6 +27,7 @@ def __init__(self, check, api, instance):
25
27
self .submit_metrics = check .submit_metrics
26
28
self .tagger = self .check .tagger
27
29
self .external_host_tags = self .check .external_host_tags
30
+ self .ndm_metadata = check .ndm_metadata
28
31
29
32
def collect (self ):
30
33
fabric_pods = self .api .get_fabric_pods ()
@@ -70,6 +73,7 @@ def submit_nodes_health(self, nodes, pods):
70
73
continue
71
74
self .log .info ("processing node %s on pod %s" , node_id , pod_id )
72
75
try :
76
+ self .submit_node_metadata (node_attrs , tags )
73
77
self .submit_process_metric (n , tags + self .check_tags + user_tags , hostname = hostname )
74
78
except (exceptions .APIConnectionException , exceptions .APIParsingException ):
75
79
pass
@@ -209,3 +213,34 @@ def get_fabric_type(self, obj_type):
209
213
return 'pod'
210
214
if obj_type == 'l1PhysIf' :
211
215
return 'port'
216
+
217
+ def submit_node_metadata (self , node_attrs , tags ):
218
+ vendor = 'cisco_aci'
219
+ namespace = 'default'
220
+ node = Node (attributes = node_attrs )
221
+ id_tags = [
222
+ f'namespace:{ namespace } ' ,
223
+ f'system_ip:{ node .attributes .address } '
224
+ ]
225
+ device_tags = [
226
+ f'device_vendor:{ vendor } ' ,
227
+ f'device_namespace:{ namespace } ' ,
228
+ f'device_hostname:{ node .attributes .dn } ' ,
229
+ f'hostname:{ node .attributes .dn } ' ,
230
+ f'system_ip:{ node .attributes .address } ' ,
231
+ f'device_ip:{ node .attributes .address } ' ,
232
+ f'device_id:{ namespace } :{ node .attributes .address } ' ,
233
+ ]
234
+ device = DeviceMetadata (
235
+ device_id = f'{ namespace } :{ node .attributes .address } ' ,
236
+ id_tags = id_tags ,
237
+ tags = device_tags + tags ,
238
+ name = node .attributes .dn ,
239
+ ip_address = node .attributes .address ,
240
+ model = node .attributes .model ,
241
+ adSt = node .attributes .adSt ,
242
+ vendor = vendor ,
243
+ version = node .attributes .version ,
244
+ serial_number = node .attributes .serial
245
+ )
246
+ self .ndm_metadata (json .dumps (device .model_dump ()))
0 commit comments