Skip to content

Commit

Permalink
Give thresholds generic nameing
Browse files Browse the repository at this point in the history
makes it so the graphite metric paths have generic names,
instead of names specific to the juniper columns.
Any sensor threshold will have the same naming,
no matter what type of sensor it is. all you need
to know is the netbox, the sensor and the type of
threshold you want (high alarm, low alarm etc)
  • Loading branch information
stveit committed Nov 24, 2022
1 parent e2e869b commit ebc385d
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions python/nav/mibs/juniper_dom_mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from nav.mibs.mibretriever import MibRetriever
from nav.models.manage import Sensor

COLUMNS = {
SENSOR_COLUMNS = {
"jnxDomCurrentRxLaserPower": {
"unit_of_measurement": Sensor.UNIT_DBM,
"precision": 2,
Expand Down Expand Up @@ -52,30 +52,30 @@
}

THRESHOLD_COLUMNS = {
"jnxDomCurrentRxLaserPower": [
"jnxDomCurrentRxLaserPowerHighAlarmThreshold",
"jnxDomCurrentRxLaserPowerLowAlarmThreshold",
"jnxDomCurrentRxLaserPowerHighWarningThreshold",
"jnxDomCurrentRxLaserPowerLowWarningThreshold",
],
"jnxDomCurrentTxLaserBiasCurrent": [
"jnxDomCurrentTxLaserBiasCurrentHighAlarmThreshold",
"jnxDomCurrentTxLaserBiasCurrentLowAlarmThreshold",
"jnxDomCurrentTxLaserBiasCurrentHighWarningThreshold",
"jnxDomCurrentTxLaserBiasCurrentLowWarningThreshold",
],
"jnxDomCurrentTxLaserOutputPower": [
"jnxDomCurrentTxLaserOutputPowerHighAlarmThreshold",
"jnxDomCurrentTxLaserOutputPowerLowAlarmThreshold",
"jnxDomCurrentTxLaserOutputPowerHighWarningThreshold",
"jnxDomCurrentTxLaserOutputPowerLowWarningThreshold",
],
"jnxDomCurrentModuleTemperature": [
"jnxDomCurrentModuleTemperatureHighAlarmThreshold",
"jnxDomCurrentModuleTemperatureLowAlarmThreshold",
"jnxDomCurrentModuleTemperatureHighWarningThreshold",
"jnxDomCurrentModuleTemperatureLowWarningThreshold",
],
"jnxDomCurrentRxLaserPower": {
"high_alarm_threshold": "jnxDomCurrentRxLaserPowerHighAlarmThreshold",
"low_alarm_threshold": "jnxDomCurrentRxLaserPowerLowAlarmThreshold",
"high_warning_threshold": "jnxDomCurrentRxLaserPowerHighWarningThreshold",
"low_warning_threshold": "jnxDomCurrentRxLaserPowerLowWarningThreshold",
},
"jnxDomCurrentTxLaserBiasCurrent": {
"high_alarm_threshold": "jnxDomCurrentTxLaserBiasCurrentHighAlarmThreshold",
"low_alarm_threshold": "jnxDomCurrentTxLaserBiasCurrentLowAlarmThreshold",
"high_warning_threshold": "jnxDomCurrentTxLaserBiasCurrentHighWarningThreshold",
"low_warning_threshold": "jnxDomCurrentTxLaserBiasCurrentLowWarningThreshold",
},
"jnxDomCurrentTxLaserOutputPower": {
"high_alarm_threshold": "jnxDomCurrentTxLaserOutputPowerHighAlarmThreshold",
"low_alarm_threshold": "jnxDomCurrentTxLaserOutputPowerLowAlarmThreshold",
"high_warning_threshold": "jnxDomCurrentTxLaserOutputPowerHighWarningThreshold",
"low_warning_threshold": "jnxDomCurrentTxLaserOutputPowerLowWarningThreshold",
},
"jnxDomCurrentModuleTemperature": {
"high_alarm_threshold": "jnxDomCurrentModuleTemperatureHighAlarmThreshold",
"low_alarm_threshold": "jnxDomCurrentModuleTemperatureLowAlarmThreshold",
"high_warning_threshold": "jnxDomCurrentModuleTemperatureHighWarningThreshold",
"low_warning_threshold": "jnxDomCurrentModuleTemperatureLowWarningThreshold",
},
}


Expand All @@ -90,7 +90,7 @@ def get_all_sensors(self):
device.
"""
sensors = []
for column, config in COLUMNS.items():
for column, config in SENSOR_COLUMNS.items():
sensors += yield self.handle_sensor_column(column, config)
returnValue(sensors)

Expand All @@ -115,16 +115,16 @@ def handle_sensor_column(self, column, config):
@defer.inlineCallbacks
def get_all_thresholds(self):
thresholds = []
for sensor_column, threshold_columns in THRESHOLD_COLUMNS.items():
for sensor_column, thresholds in THRESHOLD_COLUMNS.items():
sensor_oid = self.nodes[sensor_column].oid
for threshold_column in threshold_columns:
for threshold_name, threshold_column in thresholds.items():
thresholds += yield self.handle_threshold_column(
threshold_column, sensor_oid
threshold_column, threshold_name, sensor_oid
)
returnValue(thresholds)

@defer.inlineCallbacks
def handle_threshold_column(self, column, sensor_oid):
def handle_threshold_column(self, column, name, sensor_oid):
"""Returns the sensor thresholds of the given type"""
result = []
value_oid = self.nodes[column].oid
Expand All @@ -133,7 +133,7 @@ def handle_threshold_column(self, column, sensor_oid):
threshold = dict(
oid=str(value_oid + row),
mib=self.get_module_name(),
name=column,
name=name,
value=value,
sensor_oid=str(sensor_oid + row),
)
Expand Down

0 comments on commit ebc385d

Please sign in to comment.