detect OpenBSD sensors

This commit is contained in:
sthen
2015-10-12 15:15:14 +01:00
parent 92c2b3a14e
commit 2544dfedb5
2 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
<?php
echo ' OPENBSD-SENSORS-MIB: ';
echo 'Caching OIDs:';
$oids = array();
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 = $entity_array[$index]['sensorDevice'].' '.$entity_array[$index]['sensorDescr'];
$bogus = false;
$type = $entitysensor[$entry['sensorType']];
if ($type == 'voltage') {
$descr = preg_replace('/ (voltages|voltage)/i', '', $descr);
}
if ($type == 'temperature') {
if ($current < -40 || $current > 200) {
$bogus = true;
}
$descr = preg_replace('/ (temperature|temp)/i', '', $descr);
}
if ($current == '-127') {
$bogus = true;
}
// 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";

View File

@@ -12,6 +12,10 @@ if ($device['os'] == 'netscaler') {
include 'includes/discovery/sensors-netscaler.inc.php';
}
if ($device['os'] == 'openbsd') {
include 'includes/discovery/sensors-openbsd.inc.php';
}
require 'includes/discovery/temperatures.inc.php';
require 'includes/discovery/humidity.inc.php';
require 'includes/discovery/voltages.inc.php';