<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage discovery * @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited * */ // This could probably do with a rewrite, I suspect there's 1 table that can be walked for all the info below instead of 4. // Also, all types should be equal, not brocade-dom, brocade-dom-tx and brocade-dom-rx (requires better indexes too) $oids = snmpwalk_cache_oid($device, "snIfOpticalMonitoringTxBiasCurrent", array(), "FOUNDRY-SN-SWITCH-GROUP-MIB"); $scale = si_to_scale('milli'); foreach ($oids as $index => $entry) { $value = $entry['snIfOpticalMonitoringTxBiasCurrent']; if (!preg_match("|N/A|", $value)) { //$descr = snmp_get($device, "ifDescr.$index", "-Oqv", "IF-MIB") . " DOM TX Bias Current"; $oid = ".1.3.6.1.4.1.1991.1.1.3.3.6.1.4.{$index}"; $options = array('entPhysicalIndex' => $index); $port = get_port_by_index_cache($device['device_id'], $index); if (is_array($port)) { $descr = $port["ifDescr"] ? $port["ifDescr"] : $port["ifName"]; $options['measured_class'] = 'port'; $options['measured_entity'] = $port['port_id']; } else { $descr = snmp_get($device, "ifDescr.{$index}", "-Oqv", "IF-MIB"); } $descr .= " DOM TX Bias Current";
} else { if (!$entry['entPhysicalDescr'] && $entry['entPhysicalName']) { $descr = rewrite_entity_name($entry['entPhysicalName']); } else { if (!$entry['entPhysicalDescr'] && !$entry['entPhysicalName']) { // This is also trick for some retard devices like NetMan Plus $descr = nicecase($type); } } } if ($device['os'] == 'asa' && $entry['entPhySensorScale'] == 'yocto' && $entry['entPhySensorPrecision'] == '0') { // Hardcoded fix for Cisco ASA 9.1.5 (can be other) bug when all scales equals yocto (OBSERVIUM-1110) $scale = 1; } else { if (isset($entry['entPhySensorScale'])) { $scale = si_to_scale($entry['entPhySensorScale'], $entry['entPhySensorPrecision']); } else { // Some devices not report scales, like NetMan Plus. But this is really HACK // Heh, I not know why only ups.. I'm not sure that this for all ups.. just I see this only on NetMan Plus. $scale = $device['os_group'] == 'ups' && $type == 'temperature' ? 0.1 : 1; } } $value = $entry['entPhySensorValue']; if ($type == 'temperature') { if ($value * $scale > 200 || $value == 0) { $ok = FALSE; } } if ($value == -127) { $ok = FALSE; }
// <LIST OF UNITS: none(-1), other(0), volt(1), amp(2), watt(3), voltamp(4), wattHour(5), voltampHour(6), degreeC(7), hertz(8), percent(9), // meterpersec(10), pascal(11), psi(12), g(13), degreeF(14), feet(15), inches(16), cm(17), meters(18)> // PDU-MIB::externalSensorUnits.2 = INTEGER: degreeC(7) // PDU-MIB::externalSensorDecimalDigits.1 = Gauge32: 0 // PDU-MIB::externalSensorDecimalDigits.2 = Gauge32: 1 // PDU-MIB::externalSensorLowerCriticalThreshold.1 = INTEGER: 3 // PDU-MIB::externalSensorLowerCriticalThreshold.2 = INTEGER: 180 // PDU-MIB::externalSensorLowerWarningThreshold.1 = INTEGER: 7 // PDU-MIB::externalSensorLowerWarningThreshold.2 = INTEGER: 200 // PDU-MIB::externalSensorUpperCriticalThreshold.1 = INTEGER: 90 // PDU-MIB::externalSensorUpperCriticalThreshold.2 = INTEGER: 350 // PDU-MIB::externalSensorUpperWarningThreshold.1 = INTEGER: 85 // PDU-MIB::externalSensorUpperWarningThreshold.2 = INTEGER: 330 // PDU-MIB::externalSensorState.1 = INTEGER: normal(4) // PDU-MIB::externalSensorState.2 = INTEGER: normal(4) // PDU-MIB::externalSensorValue.1 = INTEGER: 0 // PDU-MIB::externalSensorValue.2 = INTEGER: 0 foreach ($oids as $index => $entry) { $descr = $entry['externalSensorName']; // The name set by the device's admin through Raritan's web interface. $oid = ".1.3.6.1.4.1.13742.4.3.3.1.41.{$index}"; $scale = si_to_scale('units', $entry['externalSensorDecimalDigits']); // FIXME. other scale for externalSensorUnits = degreeF $limits = array('limit_high' => $entry['externalSensorUpperWarningThreshold'] * $scale, 'limit_low' => $entry['externalSensorLowerCriticalThreshold'] * $scale, 'limit_high_warn' => $entry['externalSensorUpperCriticalThreshold'] * $scale, 'limit_low_warn' => $entry['externalSensorLowerWarningThreshold'] * $scale); $value = $entry['externalSensorValue']; $r_types = array('rmsCurrent' => 'current', 'rmsVoltage' => 'voltage', 'activePower' => 'power', 'apparentPower' => 'apower', 'temperature' => 'temperature', 'humidity' => 'humidity', 'airFlow' => 'airflow'); if (isset($r_types[$entry['externalSensorType']]) && is_numeric($value)) { discover_sensor($valid['sensor'], $r_types[$entry['externalSensorType']], $device, $oid, $index, 'raritan', $descr, $scale, $value * $scale, $limits); } } // EOF
if ($value != 0) { discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'lambdadriver-dom-temp', $descr, $scale, $value); } } if ($entry['oaSfpDiagnosticVcc'] != 'empty') { $descr = $xdescr . ' SFP supply voltage'; $scale = 0.0001; $oid = ".1.3.6.1.4.1.6926.1.18.1.1.3.1.4.{$index}"; $value = intval($entry['oaSfpDiagnosticVcc']); if ($value != 0) { discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, 'lambdadriver-dom-voltage', $descr, $scale, $value); } } if ($entry['oaSfpDiagnosticTxBias'] != 'empty') { $descr = $xdescr . ' DOM Current'; $scale = si_to_scale('micro'); $oid = ".1.3.6.1.4.1.6926.1.18.1.1.3.1.5.{$index}"; $value = intval($entry['oaSfpDiagnosticTxBias']); if ($value != 0) { discover_sensor($valid['sensor'], 'current', $device, $oid, $index, 'lambdadriver-dom-current', $descr, $scale, $value); } } if ($entry['oaSfpDiagnosticRxPower'] != 'empty') { $descr = $xdescr . ' RX'; $scale = 0.01; $oid = ".1.3.6.1.4.1.6926.1.18.1.1.3.1.7.{$index}"; $value = intval($entry['oaSfpDiagnosticRxPower']); if ($value != -5000) { discover_sensor($valid['sensor'], 'dbm', $device, $oid, $index, 'lambdadriver-dom-rxpower', $descr, $scale, $value); } }
$scale = si_to_scale($entry['mtvalExp'] + 3); // Convert to Wh // not break here case 'wh': $sensor_type = 'energy'; break; */ /* FIXME. Wh should be counters, disabled for now case 'kwh': $scale = si_to_scale($entry['mtvalExp'] + 3); // Convert to Wh // not break here case 'wh': $sensor_type = 'energy'; break; */ case 'kw': $scale = si_to_scale($entry['mtvalExp'] + 3); // Convert to W // not break here // Convert to W // not break here case 'w': $sensor_type = 'power'; break; case 'v': $sensor_type = 'voltage'; break; case 'a': $sensor_type = 'current'; break; case '': if (stristr($entry['mtvalName'], 'Power factor')) {
//BLUECOAT-SG-SENSOR-MIB::deviceSensorValue.10 = INTEGER: 1194 //BLUECOAT-SG-SENSOR-MIB::deviceSensorValue.11 = INTEGER: 330 //BLUECOAT-SG-SENSOR-MIB::deviceSensorCode.11 = INTEGER: ok(1) //BLUECOAT-SG-SENSOR-MIB::deviceSensorStatus.11 = INTEGER: ok(1) //BLUECOAT-SG-SENSOR-MIB::deviceSensorTimeStamp.11 = Timeticks: (3426521929) 396 days, 14:06:59.29 Hundredths of seconds //BLUECOAT-SG-SENSOR-MIB::deviceSensorName.11 = STRING: +3.3V bus voltage 2 (Vcc) echo " BLUECOAT-SG-SENSOR-MIB "; $sensor_array = snmpwalk_cache_multi_oid($device, 'deviceSensorValueTable', array(), 'BLUECOAT-SG-SENSOR-MIB', mib_dirs('bluecoat')); $sensor_type_map = array('volts' => 'voltage', 'rpm' => 'fanspeed', 'celsius' => 'temperature', 'dBm' => 'dbm'); foreach ($sensor_array as $index => $entry) { if ($sensor_type_map[$entry['deviceSensorUnits']] && is_numeric($entry['deviceSensorValue']) && is_numeric($index) && $entry['deviceSensorStatus'] != 'unavailable' && $entry['deviceSensorStatus'] != 'nonoperational') { $ok = TRUE; $descr = rewrite_entity_name($entry['deviceSensorName']); $oid = ".1.3.6.1.4.1.3417.2.1.1.1.1.1.5." . $index; $type = $sensor_type_map[$entry['deviceSensorUnits']]; $scale = si_to_scale($entry['deviceSensorScale']); $value = $entry['deviceSensorValue']; if ($type == "temperature") { if ($value * $scale > 200) { $ok = FALSE; } } if ($value == "-127") { $ok = FALSE; } if ($ok) { discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'bluecoat-sg-proxy-mib', $descr, $scale, $value); } } } unset($sensor_type_map, $oids, $oids_arista, $sensor_array, $index, $scale, $type, $value, $descr, $ok);
// SensorUnitsEnumeration $oid_units = array('volt' => array('type' => 'voltage'), 'amp' => array('type' => 'current'), 'watt' => array('type' => 'power'), 'voltamp' => array('type' => 'apower'), 'degreeC' => array('type' => 'temperature', 'unit' => 'C'), 'hertz' => array('type' => 'frequency'), 'percent' => array('type' => 'humidity'), 'meterpersec' => array('type' => 'velocity'), 'pascal' => array('type' => 'pressure'), 'psi' => array('type' => 'pressure', 'unit' => 'psi'), 'degreeF' => array('type' => 'temperature', 'unit' => 'F'), 'rpm' => array('type' => 'fanspeed'), 'lux' => array('type' => 'illuminance'), 'voltampReactive' => array('type' => 'rpower')); $oids = snmpwalk_cache_oid($device, 'externalSensorConfigurationEntry', array(), $mib); $oids = snmpwalk_cache_oid($device, 'externalSensorMeasurementsEntry', $oids, $mib); if (OBS_DEBUG > 1) { print_vars($oids); } foreach ($oids as $index => $entry) { if (!in_array($entry['externalSensorType'], $oid_types) || $entry['measurementsExternalSensorIsAvailable'] == 'false') { continue; } $descr = $entry['externalSensorName']; if ($entry['externalSensorPort']) { $descr .= ' - ' . $entry['externalSensorPort']; } $scale = si_to_scale($entry['externalSensorDecimalDigits'] * -1); $oid_name = 'measurementsExternalSensorValue'; $oid_num = '.1.3.6.1.4.1.13742.8.2.1.1.1.3.' . $index; $type = $mib . '-' . $oid_name; $value = $entry[$oid_name]; // Limits (based on enabled thresholds) // SYNTAX BITS { // lowerCritical(0), // lowerWarning(1), // upperWarning(2), // upperCritical(3), // } $options = array(); $limits_flags = base_convert($entry['externalSensorEnabledThresholds'], 16, 10); if (is_flag_set(bindec(10000000), $limits_flags)) { $options['limit_low'] = $entry['externalSensorLowerCriticalThreshold'] * $scale;
/** * @dataProvider providerSiToScaleValue */ public function testSiToScaleValue($value, $scale, $result) { $this->assertSame($result, $value * si_to_scale($scale)); }
$oid_num = ".1.3.6.1.4.1.1916.1.1.1.38.1.3.{$index}"; $type = $mib . '-' . $oid_name; discover_sensor($valid['sensor'], 'voltage', $device, $oid_num, $index, $type, $descr, $scale, $value, $options); } $oid_name = 'extremePowerSupplyOutputCurrent'; $value = $entry[$oid_name]; if ($value > 0) { $oid_num = ".1.3.6.1.4.1.1916.1.1.1.38.1.4.{$index}"; $type = $mib . '-' . $oid_name; discover_sensor($valid['sensor'], 'current', $device, $oid_num, $index, $type, $descr, $scale, $value, $options); } } } // FIXME, actual only for stacked devices, or it same as power supply power usage //EXTREME-SYSTEM-MIB::extremeSystemPowerUsageValue.0 = INTEGER: 74800 //EXTREME-SYSTEM-MIB::extremeSystemPowerUsageUnitMultiplier.0 = INTEGER: milli(-3) $oids['SystemPowerUsage'] = snmpget_cache_multi($device, 'extremeSystemPowerUsageValue.0 extremeSystemPowerUsageUnitMultiplier.0', array(), $mib); //print_vars($oids); $index = 0; $entry = $oids['SystemPowerUsage'][$index]; $descr = 'Total Power Usage'; $scale = si_to_scale($entry['extremeSystemPowerUsageUnitMultiplier']); $oid_name = 'extremeSystemPowerUsageValue'; $value = $entry[$oid_name]; if ($value > 0) { $oid_num = ".1.3.6.1.4.1.1916.1.1.1.40.1.{$index}"; $type = $mib . '-' . $oid_name; discover_sensor($valid['sensor'], 'power', $device, $oid_num, $index, $type, $descr, $scale, $value); } unset($oids); // EOF
SUN-PLATFORM-MIB::sunPlatNumericSensorEnabledThresholds.15 = BITS: 00 SUN-PLATFORM-MIB::sunPlatNumericSensorRestoreDefaultThresholds.5 = INTEGER: reset(1) SUN-PLATFORM-MIB::sunPlatNumericSensorRestoreDefaultThresholds.15 = INTEGER: reset(1) SUN-PLATFORM-MIB::sunPlatEquipmentLocationName.5 = STRING: /CH/CMM SUN-PLATFORM-MIB::sunPlatEquipmentLocationName.15 = STRING: /CH/BL0 */ $SunPlatBaseUnits = array('degC' => array('type' => 'temperature', 'unit' => 'C'), 'degF' => array('type' => 'temperature', 'unit' => 'F'), 'degK' => array('type' => 'temperature', 'unit' => 'K'), 'volts' => array('type' => 'voltage'), 'amps' => array('type' => 'current'), 'watts' => array('type' => 'power'), 'va' => array('type' => 'apower'), 'lux' => array('type' => 'illuminance'), 'kPa' => array('type' => 'pressure'), 'psi' => array('type' => 'pressure', 'unit' => 'psi'), 'cfm' => array('type' => 'airflow'), 'rpm' => array('type' => 'fanspeed'), 'hertz' => array('type' => 'frequency'), 'ohms' => array('type' => 'resistance')); $oids = snmpwalk_cache_oid($device, 'sunPlatNumericSensorEntry', array(), $mib); $oids = snmpwalk_cache_oid($device, 'sunPlatEquipmentLocationName', $oids, $mib); foreach ($oids as $index => $entry) { if (!isset($entry['sunPlatNumericSensorBaseUnits']) || !isset($SunPlatBaseUnits[$entry['sunPlatNumericSensorBaseUnits']]) || !isset($entry['sunPlatNumericSensorCurrent'])) { continue; } $descr = $entry['sunPlatEquipmentLocationName']; $scale = si_to_scale($entry['sunPlatNumericSensorExponent']); $oid_name = 'sunPlatNumericSensorCurrent'; $oid_num = '.1.3.6.1.4.1.42.2.70.101.1.1.8.1.4.' . $index; $type = $mib . '-' . $oid_name; $value = $entry[$oid_name]; // Limits (based on enabled thresholds) // SYNTAX BITS { // lowerThresholdNonCritical(0), // upperThresholdNonCritical(1), // lowerThresholdCritical(2), // upperThresholdCritical(3), // lowerThresholdFatal(4), // upperThresholdFatal(5) // } $options = array(); $limits_flags = base_convert($entry['sunPlatNumericSensorEnabledThresholds'], 16, 10);
foreach ($oids[$index] as $type => $entry) { if (!in_array($entry['rlPhyTestGetStatus'], array('success', 'inProgress'))) { continue; } switch ($entry['rlPhyTestGetUnits']) { case 'microVolt': case 'microAmper': case 'microOham': case 'microWatt': $scale = si_to_scale('micro'); break; case 'milidbm': $scale = si_to_scale('milli'); break; case 'decidbm': $scale = si_to_scale('deci'); break; default: $scale = 1; } $options = array('entPhysicalIndex' => $index); $port = get_port_by_index_cache($device['device_id'], $index); if (is_array($port)) { $entry['ifDescr'] = $port['ifDescr']; $options['measured_class'] = 'port'; $options['measured_entity'] = $port['port_id']; } else { $entry['ifDescr'] = snmp_get($device, "ifDescr." . $index, "-Oqv", "IF-MIB"); } switch ($type) { case 'rlPhyTestTableTransceiverTemp':