Skip to content

Commit 378428d

Browse files
[ODOS-183] Adding CiscoEntitySensor MIB for Sensor Thresholds
1 parent 005bbc9 commit 378428d

7 files changed

+1275
-10
lines changed

src/sonic_ax_impl/main.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class SonicMIB(
4141
cisco.ciscoPfcExtMIB.cpfcIfPriorityTable,
4242
cisco.ciscoSwitchQosMIB.csqIfQosGroupStatsTable,
4343
cisco.ciscoEntityFruControlMIB.cefcFruPowerStatusTable,
44+
cisco.ciscoEntitySensorMIB.CiscoPhysicalSensorThresholdMIB,
45+
cisco.ciscoEntitySensorMIB.CiscoPhysicalSensorValueTableMIB,
4446
):
4547
"""
4648
If SONiC was to create custom MIBEntries, they may be specified here.

src/sonic_ax_impl/mibs/ietf/physical_entity_sub_oid_generator.py

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
DEVICE_INDEX_MULTIPLE = 100
6161
DEVICE_TYPE_PS = 1 * DEVICE_TYPE_MULTIPLE
6262
DEVICE_TYPE_FAN = 2 * DEVICE_TYPE_MULTIPLE
63+
DEVICE_TYPE_PSU_THERMAL = 98 * DEVICE_TYPE_MULTIPLE
6364
DEVICE_TYPE_CHASSIS_THERMAL = 99 * DEVICE_TYPE_MULTIPLE
6465
DEVICE_TYPE_POWER_MONITOR = 24 * DEVICE_TYPE_MULTIPLE
6566

@@ -96,6 +97,15 @@ def get_chassis_thermal_sub_id(position):
9697
"""
9798
return (CHASSIS_MGMT_SUB_ID + DEVICE_TYPE_CHASSIS_THERMAL + position * DEVICE_INDEX_MULTIPLE + SENSOR_TYPE_TEMP, )
9899

100+
def get_psu_thermal_sub_id(position):
101+
"""
102+
Returns sub OID for thermals that belong to PSU. Sub OID is calculated as follows:
103+
sub OID = CHASSIS_MGMT_SUB_ID + DEVICE_TYPE_PSU_THERMAL + position * DEVICE_INDEX_MULTIPLE + SENSOR_TYPE_TEMP,
104+
:param position: thermal position
105+
:return: sub OID of the thermal
106+
"""
107+
return (CHASSIS_MGMT_SUB_ID + DEVICE_TYPE_PSU_THERMAL + position * DEVICE_INDEX_MULTIPLE + SENSOR_TYPE_TEMP, )
108+
99109
def get_fan_sub_id(parent_id, position):
100110
"""
101111
Returns sub OID for fan. Sub OID is calculated as follows:

src/sonic_ax_impl/mibs/ietf/sensor_data.py

+32-10
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,46 @@ class TransceiverSensorData(BaseSensorData):
8888
'name': 'Temperature',
8989
'oid_offset_base': SENSOR_TYPE_TEMP,
9090
'sort_factor': 0,
91-
'lane_based_sensor': False
91+
'lane_based_sensor': False,
92+
'highalarmkey' : 'temphighalarm',
93+
'lowalarmkey' : 'templowalarm'
94+
9295
},
9396
'voltage': {
9497
'pattern': 'voltage',
9598
'name': 'Voltage',
9699
'oid_offset_base': SENSOR_TYPE_VOLTAGE,
97100
'sort_factor': 9000,
98-
'lane_based_sensor': False
101+
'lane_based_sensor': False,
102+
'highalarmkey':'vcchighalarm',
103+
'lowalarmkey':'vcclowalarm'
99104
},
100105
'rxpower': {
101106
'pattern': r'rx(\d+)power',
102107
'name': 'RX Power',
103108
'oid_offset_base': SENSOR_TYPE_PORT_RX_POWER,
104109
'sort_factor': 2000,
105-
'lane_based_sensor': True
110+
'lane_based_sensor': True,
111+
'highalarmkey':'rxpowerhighalarm',
112+
'lowalarmkey':'rxpowerlowalarm'
106113
},
107114
'txpower': {
108115
'pattern': r'tx(\d+)power',
109116
'name': 'TX Power',
110117
'oid_offset_base': SENSOR_TYPE_PORT_TX_POWER,
111118
'sort_factor': 1000,
112-
'lane_based_sensor': True
119+
'lane_based_sensor': True,
120+
'highalarmkey':'txpowerhighalarm',
121+
'lowalarmkey': 'txpowerlowalarm'
113122
},
114123
'txbias': {
115124
'pattern': r'tx(\d+)bias',
116125
'name': 'TX Bias',
117126
'oid_offset_base': SENSOR_TYPE_PORT_TX_BIAS,
118127
'sort_factor': 3000,
119-
'lane_based_sensor': True
128+
'lane_based_sensor': True,
129+
'highalarmkey':'txbiashighalarm',
130+
'lowalarmkey':'txbiaslowalarm'
120131
}
121132
}
122133

@@ -171,25 +182,34 @@ class PSUSensorData(BaseSensorData):
171182
'pattern': 'temp',
172183
'name': 'Temperature',
173184
'oid_offset_base': SENSOR_TYPE_TEMP,
174-
'sort_factor': 0
185+
'sort_factor': 0,
186+
'highalarmkey':'high_threshold',
187+
'lowalarmkey':'low_threshold'
188+
175189
},
176190
'voltage': {
177191
'pattern': 'voltage',
178192
'name': 'Voltage',
179193
'oid_offset_base': SENSOR_TYPE_VOLTAGE,
180-
'sort_factor': 9000
194+
'sort_factor': 9000,
195+
'highalarmkey':'voltage_max_threshold',
196+
'lowalarmkey':'voltage_min_threshold'
181197
},
182198
'power': {
183199
'pattern': 'power',
184200
'name': 'Power',
185201
'oid_offset_base': SENSOR_TYPE_POWER,
186-
'sort_factor': 2000
202+
'sort_factor': 2000,
203+
'highalarmkey':'power_max_threshold',
204+
'lowalarmkey':'power_max_threshold'
187205
},
188206
'current': {
189207
'pattern': 'current',
190208
'name': 'Current',
191209
'oid_offset_base': SENSOR_TYPE_CURRENT,
192-
'sort_factor': 1000
210+
'sort_factor': 1000,
211+
'highalarmkey':'current_max_threshold',
212+
'lowalarmkey':'current'
193213
}
194214
}
195215

@@ -259,7 +279,9 @@ class ThermalSensorData(BaseSensorData):
259279
'pattern': 'temperature',
260280
'name': 'Temperature',
261281
'oid_offset_base': SENSOR_TYPE_TEMP,
262-
'sort_factor': 0
282+
'sort_factor': 0,
283+
'highalarmkey':'high_threshold',
284+
'lowalarmkey':'low_threshold'
263285
}
264286
}
265287

src/sonic_ax_impl/mibs/vendor/cisco/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
from . import ciscoPfcExtMIB
33
from . import ciscoSwitchQosMIB
44
from . import ciscoEntityFruControlMIB
5+
from . import ciscoEntitySensorMIB
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from .cisco_sensor_threshold import CiscoPhysicalSensorThretholdTableMIBUpdater
2+
from .cisco_sensor_value import CiscoValuePhysicalSensorTableMIBUpdater
3+
from ax_interface import MIBMeta, MIBUpdater, ValueType, SubtreeMIBEntry
4+
5+
6+
7+
class CiscoPhysicalSensorThresholdMIB(metaclass=MIBMeta, prefix='.1.3.6.1.4.1.9.9.91.1.2.1'):
8+
"""
9+
Sensor thresholds table.
10+
"""
11+
12+
updater = CiscoPhysicalSensorThretholdTableMIBUpdater()
13+
14+
entSensorHighThresholdSeverity = \
15+
SubtreeMIBEntry('1.2.1', updater, ValueType.INTEGER, updater.get_high_sensors_severity)
16+
17+
entSensorLowThresholdSeverity = \
18+
SubtreeMIBEntry('1.2.2', updater, ValueType.INTEGER, updater.get_low_sensors_severity)
19+
20+
21+
entSensorHighThresholdRelation = \
22+
SubtreeMIBEntry('1.3.1', updater, ValueType.INTEGER, updater.get_high_sensors_relation)
23+
24+
entSensorLowThresholdRelation = \
25+
SubtreeMIBEntry('1.3.2', updater, ValueType.INTEGER, updater.get_low_sensors_relation)
26+
27+
entSensorHighThresholdValue = \
28+
SubtreeMIBEntry('1.4.1', updater, ValueType.OCTET_STRING, updater.get_high_sensors_threshold)
29+
30+
entSensorLowThresholdValue = \
31+
SubtreeMIBEntry('1.4.2', updater, ValueType.OCTET_STRING, updater.get_low_sensors_threshold)
32+
33+
entSensorHighThresholdEvaluation = \
34+
SubtreeMIBEntry('1.5.1', updater, ValueType.INTEGER, updater.get_high_sensors_evaluation)
35+
36+
entSensorLowThresholdEvaluation = \
37+
SubtreeMIBEntry('1.5.2', updater, ValueType.INTEGER, updater.get_low_sensors_evaluation)
38+
39+
entSensorHighThresholdNotificationEnable = \
40+
SubtreeMIBEntry('1.6.1', updater, ValueType.INTEGER, updater.get_high_sensors_notification)
41+
42+
entSensorLowThresholdNotificationEnable = \
43+
SubtreeMIBEntry('1.6.2', updater, ValueType.INTEGER, updater.get_low_sensors_notification)
44+
45+
46+
class CiscoPhysicalSensorValueTableMIB(metaclass=MIBMeta, prefix='.1.3.6.1.4.1.9.9.91.1.1.1'):
47+
"""
48+
Sensor Value table.
49+
"""
50+
51+
updater = CiscoValuePhysicalSensorTableMIBUpdater()
52+
53+
entPhySensorType = \
54+
SubtreeMIBEntry('1.1', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_type)
55+
56+
entPhySensorScale = \
57+
SubtreeMIBEntry('1.2', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_scale)
58+
59+
entPhySensorPrecision = \
60+
SubtreeMIBEntry('1.3', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_precision)
61+
62+
entPhySensorValue = \
63+
SubtreeMIBEntry('1.4', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_value)
64+
65+
entPhySensorStatus = \
66+
SubtreeMIBEntry('1.5', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_oper_status)

0 commit comments

Comments
 (0)