mirror of
https://github.com/librenms/librenms.git
synced 2024-09-22 02:48:37 +00:00
7f104d4fd9
* 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
64 lines
2.3 KiB
PHP
64 lines
2.3 KiB
PHP
<?php
|
|
|
|
echo ' OPENBSD-SENSORS-MIB: ';
|
|
|
|
echo 'Caching OIDs:';
|
|
|
|
$oids = [];
|
|
echo ' sensorDevice';
|
|
$oids = snmpwalk_cache_multi_oid($device, 'sensorDevice', $oids, 'OPENBSD-SENSORS-MIB');
|
|
echo ' sensorDescr';
|
|
$oids = snmpwalk_cache_multi_oid($device, 'sensorDescr', $oids, 'OPENBSD-SENSORS-MIB');
|
|
echo ' sensorValue';
|
|
$oids = snmpwalk_cache_multi_oid($device, 'sensorValue', $oids, 'OPENBSD-SENSORS-MIB');
|
|
echo ' sensorType';
|
|
$oids = snmpwalk_cache_multi_oid($device, 'sensorType', $oids, 'OPENBSD-SENSORS-MIB');
|
|
|
|
# temperature(0), fan(1), voltsdc(2), voltsac(3), resistance(4), power(5),
|
|
# current(6), watthour(7), amphour(8), indicator(9), raw(10), percent(11),
|
|
# illuminance(12), drive(13), timedelta(14), humidity(15), freq(16),
|
|
# angle(17), distance(18), pressure(19), accel(20)
|
|
|
|
$entitysensor['voltsdc'] = 'voltage';
|
|
$entitysensor['voltsac'] = 'voltage';
|
|
$entitysensor['fan'] = 'fanspeed';
|
|
|
|
$entitysensor['current'] = 'current';
|
|
$entitysensor['power'] = 'power';
|
|
$entitysensor['freq'] = 'freq';
|
|
$entitysensor['humidity'] = 'humidity';
|
|
$entitysensor['temperature'] = 'temperature';
|
|
|
|
if (is_array($oids)) {
|
|
foreach ($oids as $index => $entry) {
|
|
// echo("[" . $entry['sensorType'] . "|" . $entry['sensorValue']. "|" . $index . "] ");
|
|
if ($entitysensor[$entry['sensorType']] && is_numeric($entry['sensorValue']) && is_numeric($index)) {
|
|
$entPhysicalIndex = $index;
|
|
$oid = '.1.3.6.1.4.1.30155.2.1.2.1.5.'.$index;
|
|
$current = $entry['sensorValue'];
|
|
$descr = $entry['sensorDevice'].' '.$entry['sensorDescr'];
|
|
$bogus = false;
|
|
|
|
$type = $entitysensor[$entry['sensorType']];
|
|
|
|
if ($type == 'voltage') {
|
|
$descr = preg_replace('/ voltage/i', '', $descr);
|
|
}
|
|
|
|
if ($type == 'temperature') {
|
|
if ($current < -40 || $current > 200) {
|
|
$bogus = true;
|
|
}
|
|
$descr = preg_replace('/ temperature/i', '', $descr);
|
|
}
|
|
|
|
// echo($descr . "|" . $index . "|" .$current . "|" . $bogus . "\n");
|
|
if (! $bogus) {
|
|
discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'openbsd-sensor', $descr, '1', '1', null, null, null, null, $current);
|
|
}
|
|
}//end if
|
|
}//end foreach
|
|
}//end if
|
|
|
|
echo "\n";
|