Files
librenms-librenms/includes/discovery/sensors/temperature/sub10.inc.php
KodApa85 7f104d4fd9 Advanced state sensors (#9881)
* refactor: advanced sensor states

mark create_state_index($state_name) as E_USER_DEPRECATED?

* fix: minor corrections

* fix: mib has partialSync(9) and incompatibleVersion(8)

* fix: corrected netagent2upsstate - Sleeping(5)

* fix: NetAgent2 upsThreePhaseUPSStatusInverterOperating correction

* refactor: array() be gone

* Refactoring includes/discovery/sensors/state/extendair.inc.php with arrays
And tidying up array formatting in other files

* fix: minor typo

* standardising array item names

removed redundant "if ($state_index_id !== null) {"

* workaround: procurve & serverscheck

a sensor is causing create_state_index($state) to return null.
The updated code doesn't allow for this and thus a hybrid is being used.

* standardised naming of state info. Caused a typo $state_name instead of $status_name
$state_name is the standard

* converted compas to square arrays

* Converted APC states using preg_match to new create_state_index() call

* Update boss.inc.php
2019-03-04 11:31:17 -06:00

29 lines
1022 B
PHP

<?php
echo 'Sub10 temperature ';
// Get Current Value
$temp_oid = 'sub10UnitLclMWUTemperature.0';
list($oid, $current) = explode(' ', snmp_get($device, $temp_oid, '-OsqnU', 'SUB10SYSTEMS-MIB'));
// Get Alarm Ranges
$alarm_oid = 'sub10UnitMgmtAlarmName';
$alarms = snmp_walk($device, $alarm_oid, '-OsqU', 'SUB10SYSTEMS-MIB');
$indexes = [];
foreach (explode("\n", $alarms) as $alarm) {
if (preg_match('/^\w+\.(\d) MWU Temperature (.*)$/', $alarm, $matches)) {
$indexes[strtolower($matches[2])] = $matches[1];
}
}
$thresh_oid = 'sub10UnitMgmtAlarmRaiseThresh';
$threshes = snmp_walk($device, $thresh_oid, '-OsqU', 'SUB10SYSTEMS-MIB');
$thresholds = [];
foreach (explode("\n", $threshes) as $thresh) {
preg_match('/^\w+\.(\d) (.*)$/', $thresh, $matches);
$thresholds[$matches[1]] = $matches[2];
}
// Create Sensor
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $oid, 'sub10', 'Modem', '1', '1', $thresholds[$indexes['low']], null, null, $thresholds[$indexes['high']], $current);