Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ODOS-183] Adding CiscoEntitySensor MIB for Sensor Thresholds #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions src/sonic_ax_impl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class SonicMIB(
cisco.ciscoPfcExtMIB.cpfcIfPriorityTable,
cisco.ciscoSwitchQosMIB.csqIfQosGroupStatsTable,
cisco.ciscoEntityFruControlMIB.cefcFruPowerStatusTable,
cisco.ciscoEntitySensorMIB.CiscoPhysicalSensorThresholdMIB,
cisco.ciscoEntitySensorMIB.CiscoPhysicalSensorValueTableMIB,
):
"""
If SONiC was to create custom MIBEntries, they may be specified here.
Expand Down
10 changes: 10 additions & 0 deletions src/sonic_ax_impl/mibs/ietf/physical_entity_sub_oid_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
DEVICE_INDEX_MULTIPLE = 100
DEVICE_TYPE_PS = 1 * DEVICE_TYPE_MULTIPLE
DEVICE_TYPE_FAN = 2 * DEVICE_TYPE_MULTIPLE
DEVICE_TYPE_PSU_THERMAL = 98 * DEVICE_TYPE_MULTIPLE
DEVICE_TYPE_CHASSIS_THERMAL = 99 * DEVICE_TYPE_MULTIPLE
DEVICE_TYPE_POWER_MONITOR = 24 * DEVICE_TYPE_MULTIPLE

Expand Down Expand Up @@ -96,6 +97,15 @@ def get_chassis_thermal_sub_id(position):
"""
return (CHASSIS_MGMT_SUB_ID + DEVICE_TYPE_CHASSIS_THERMAL + position * DEVICE_INDEX_MULTIPLE + SENSOR_TYPE_TEMP, )

def get_psu_thermal_sub_id(position):
"""
Returns sub OID for thermals that belong to PSU. Sub OID is calculated as follows:
sub OID = CHASSIS_MGMT_SUB_ID + DEVICE_TYPE_PSU_THERMAL + position * DEVICE_INDEX_MULTIPLE + SENSOR_TYPE_TEMP,
:param position: thermal position
:return: sub OID of the thermal
"""
return (CHASSIS_MGMT_SUB_ID + DEVICE_TYPE_PSU_THERMAL + position * DEVICE_INDEX_MULTIPLE + SENSOR_TYPE_TEMP, )

def get_fan_sub_id(parent_id, position):
"""
Returns sub OID for fan. Sub OID is calculated as follows:
Expand Down
42 changes: 32 additions & 10 deletions src/sonic_ax_impl/mibs/ietf/sensor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,46 @@ class TransceiverSensorData(BaseSensorData):
'name': 'Temperature',
'oid_offset_base': SENSOR_TYPE_TEMP,
'sort_factor': 0,
'lane_based_sensor': False
'lane_based_sensor': False,
'highalarmkey' : 'temphighalarm',
'lowalarmkey' : 'templowalarm'

},
'voltage': {
'pattern': 'voltage',
'name': 'Voltage',
'oid_offset_base': SENSOR_TYPE_VOLTAGE,
'sort_factor': 9000,
'lane_based_sensor': False
'lane_based_sensor': False,
'highalarmkey':'vcchighalarm',
'lowalarmkey':'vcclowalarm'
},
'rxpower': {
'pattern': r'rx(\d+)power',
'name': 'RX Power',
'oid_offset_base': SENSOR_TYPE_PORT_RX_POWER,
'sort_factor': 2000,
'lane_based_sensor': True
'lane_based_sensor': True,
'highalarmkey':'rxpowerhighalarm',
'lowalarmkey':'rxpowerlowalarm'
},
'txpower': {
'pattern': r'tx(\d+)power',
'name': 'TX Power',
'oid_offset_base': SENSOR_TYPE_PORT_TX_POWER,
'sort_factor': 1000,
'lane_based_sensor': True
'lane_based_sensor': True,
'highalarmkey':'txpowerhighalarm',
'lowalarmkey': 'txpowerlowalarm'
},
'txbias': {
'pattern': r'tx(\d+)bias',
'name': 'TX Bias',
'oid_offset_base': SENSOR_TYPE_PORT_TX_BIAS,
'sort_factor': 3000,
'lane_based_sensor': True
'lane_based_sensor': True,
'highalarmkey':'txbiashighalarm',
'lowalarmkey':'txbiaslowalarm'
}
}

Expand Down Expand Up @@ -171,25 +182,34 @@ class PSUSensorData(BaseSensorData):
'pattern': 'temp',
'name': 'Temperature',
'oid_offset_base': SENSOR_TYPE_TEMP,
'sort_factor': 0
'sort_factor': 0,
'highalarmkey':'high_threshold',
'lowalarmkey':'low_threshold'

},
'voltage': {
'pattern': 'voltage',
'name': 'Voltage',
'oid_offset_base': SENSOR_TYPE_VOLTAGE,
'sort_factor': 9000
'sort_factor': 9000,
'highalarmkey':'voltage_max_threshold',
'lowalarmkey':'voltage_min_threshold'
},
'power': {
'pattern': 'power',
'name': 'Power',
'oid_offset_base': SENSOR_TYPE_POWER,
'sort_factor': 2000
'sort_factor': 2000,
'highalarmkey':'power_max_threshold',
'lowalarmkey':'power_max_threshold'
},
'current': {
'pattern': 'current',
'name': 'Current',
'oid_offset_base': SENSOR_TYPE_CURRENT,
'sort_factor': 1000
'sort_factor': 1000,
'highalarmkey':'current_max_threshold',
'lowalarmkey':'current'
}
}

Expand Down Expand Up @@ -259,7 +279,9 @@ class ThermalSensorData(BaseSensorData):
'pattern': 'temperature',
'name': 'Temperature',
'oid_offset_base': SENSOR_TYPE_TEMP,
'sort_factor': 0
'sort_factor': 0,
'highalarmkey':'high_threshold',
'lowalarmkey':'low_threshold'
}
}

Expand Down
1 change: 1 addition & 0 deletions src/sonic_ax_impl/mibs/vendor/cisco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from . import ciscoPfcExtMIB
from . import ciscoSwitchQosMIB
from . import ciscoEntityFruControlMIB
from . import ciscoEntitySensorMIB
66 changes: 66 additions & 0 deletions src/sonic_ax_impl/mibs/vendor/cisco/ciscoEntitySensorMIB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from .cisco_sensor_threshold import CiscoPhysicalSensorThretholdTableMIBUpdater
from .cisco_sensor_value import CiscoValuePhysicalSensorTableMIBUpdater
from ax_interface import MIBMeta, MIBUpdater, ValueType, SubtreeMIBEntry



class CiscoPhysicalSensorThresholdMIB(metaclass=MIBMeta, prefix='.1.3.6.1.4.1.9.9.91.1.2.1'):
"""
Sensor thresholds table.
"""

updater = CiscoPhysicalSensorThretholdTableMIBUpdater()

entSensorHighThresholdSeverity = \
SubtreeMIBEntry('1.2.1', updater, ValueType.INTEGER, updater.get_high_sensors_severity)

entSensorLowThresholdSeverity = \
SubtreeMIBEntry('1.2.2', updater, ValueType.INTEGER, updater.get_low_sensors_severity)


entSensorHighThresholdRelation = \
SubtreeMIBEntry('1.3.1', updater, ValueType.INTEGER, updater.get_high_sensors_relation)

entSensorLowThresholdRelation = \
SubtreeMIBEntry('1.3.2', updater, ValueType.INTEGER, updater.get_low_sensors_relation)

entSensorHighThresholdValue = \
SubtreeMIBEntry('1.4.1', updater, ValueType.OCTET_STRING, updater.get_high_sensors_threshold)

entSensorLowThresholdValue = \
SubtreeMIBEntry('1.4.2', updater, ValueType.OCTET_STRING, updater.get_low_sensors_threshold)

entSensorHighThresholdEvaluation = \
SubtreeMIBEntry('1.5.1', updater, ValueType.INTEGER, updater.get_high_sensors_evaluation)

entSensorLowThresholdEvaluation = \
SubtreeMIBEntry('1.5.2', updater, ValueType.INTEGER, updater.get_low_sensors_evaluation)

entSensorHighThresholdNotificationEnable = \
SubtreeMIBEntry('1.6.1', updater, ValueType.INTEGER, updater.get_high_sensors_notification)

entSensorLowThresholdNotificationEnable = \
SubtreeMIBEntry('1.6.2', updater, ValueType.INTEGER, updater.get_low_sensors_notification)


class CiscoPhysicalSensorValueTableMIB(metaclass=MIBMeta, prefix='.1.3.6.1.4.1.9.9.91.1.1.1'):
"""
Sensor Value table.
"""

updater = CiscoValuePhysicalSensorTableMIBUpdater()

entPhySensorType = \
SubtreeMIBEntry('1.1', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_type)

entPhySensorScale = \
SubtreeMIBEntry('1.2', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_scale)

entPhySensorPrecision = \
SubtreeMIBEntry('1.3', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_precision)

entPhySensorValue = \
SubtreeMIBEntry('1.4', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_value)

entPhySensorStatus = \
SubtreeMIBEntry('1.5', updater, ValueType.INTEGER, updater.get_ent_physical_sensor_oper_status)
Loading