@@ -331,6 +331,9 @@ def _get_counter(self, oid, table_name):
331
331
:return: the counter for the respective sub_id/table.
332
332
"""
333
333
# Enum.name or table_name = 'name_of_the_table'
334
+ # Example:
335
+ # table_name = <DbTables.SAI_PORT_STAT_IF_OUT_ERRORS: 20>
336
+ # _table_name = 'SAI_PORT_STAT_IF_OUT_ERRORS'
334
337
_table_name = getattr (table_name , 'name' , table_name )
335
338
336
339
try :
@@ -385,12 +388,37 @@ def get_counter(self, sub_id, table_name):
385
388
return 0
386
389
elif oid in self .oid_lag_name_map :
387
390
counter_value = 0
391
+ # Sum the values of this counter for all ports in the LAG.
392
+ # Example:
393
+ # table_name = <DbTables.SAI_PORT_STAT_IF_OUT_ERRORS: 20>
394
+ # oid = 1001
395
+ # self.oid_lag_name_map = {1001: 'PortChannel01', 1002: 'PortChannel02', 1003: 'PortChannel03'}
396
+ # self.oid_lag_name_map[oid] = 'PortChannel01'
397
+ # self.lag_name_if_name_map = {'PortChannel01': ['Ethernet112'], 'PortChannel02': ['Ethernet116'], 'PortChannel03': ['Ethernet120']}
398
+ # self.lag_name_if_name_map['PortChannel01'] = ['Ethernet112']
399
+ # mibs.get_index_from_str('Ethernet112') = 113 (because Ethernet N = N + 1)
400
+ # self._get_counter retrieves the counter per oid and table.
388
401
for lag_member in self .lag_name_if_name_map [self .oid_lag_name_map [oid ]]:
389
402
counter_value += self ._get_counter (mibs .get_index_from_str (lag_member ), table_name )
403
+ # Check if we need to add a router interface count.
404
+ # Example:
405
+ # self.lag_sai_map = {'PortChannel01': '2000000000006', 'PortChannel02': '2000000000005', 'PortChannel03': '2000000000004'}
406
+ # self.port_rif_map = {'2000000000006': '6000000000006', '2000000000005': '6000000000005', '2000000000004': '6000000000004'}
407
+ # self.rif_port_map = {'6000000000006': '2000000000006', '6000000000005': '2000000000005', '6000000000004': '2000000000004'}
408
+ # self.lag_sai_map['PortChannel01'] = '2000000000006'
409
+ # self.port_rif_map['2000000000006'] = '6000000000006'
390
410
sai_lag_id = self .lag_sai_map [self .oid_lag_name_map [oid ]]
391
411
sai_lag_rif_id = self .port_rif_map [sai_lag_id ]
392
412
if sai_lag_rif_id in self .rif_port_map :
413
+ # Extract the 'name' part of 'table_name'.
414
+ # Example:
415
+ # table_name = <DbTables.SAI_PORT_STAT_IF_OUT_ERRORS: 20>
416
+ # _table_name = 'SAI_PORT_STAT_IF_OUT_ERRORS'
393
417
table_name = getattr (table_name , 'name' , table_name )
418
+ # Find rif counter table if applicable and add the count for this table.
419
+ # Example:
420
+ # mibs.RIF_DROPS_AGGR_MAP = {'SAI_PORT_STAT_IF_IN_ERRORS': 'SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS', 'SAI_PORT_STAT_IF_OUT_ERRORS': 'SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS'}
421
+ # self.rif_counters['6000000000006'] = {'SAI_ROUTER_INTERFACE_STAT_IN_PACKETS': 6, ... 'SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_PACKETS': 6, ...}
394
422
if table_name in mibs .RIF_DROPS_AGGR_MAP :
395
423
rif_table_name = mibs .RIF_DROPS_AGGR_MAP [table_name ]
396
424
counter_value += self .rif_counters [sai_lag_rif_id ].get (rif_table_name , 0 )
0 commit comments