Files
Tony Murray 3dba5cd39d newdevice: Support Avtech RoomAlert 32E/W and RoomAlert 11E (#7614)
* newdevice: support Avtech RoomAlert 32E/W
Move avtech discovery to yaml, took a bit of trickery

* More flexibility when checking pre-cached data
A little cleanup

* Add support for RoomAlert 32E/W external and wish temp sensors
Add RoomAlert 11E support (just temp sensors)
Updated ROOMALERT32E-MIB
2017-11-04 21:25:13 +00:00

62 lines
2.0 KiB
PHP

<?php
/**
* avtech.inc.php
*
* Grab all data under avtech enterprise oid and process it for yaml consumption
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Tony Murray
* @author Tony Murray <[email protected]>
*/
// table name => regex (first group is index, second group is id)
$virtual_tables = array(
'ra32-analog' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.1\.5\.((\d+)\.0)/',
'ra32-relay' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.1\.6\.((\d+)\.0)/',
'ra32-ext-temp' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.2\.((\d+)\.1\.0)/',
'ra32-switch' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.3\.((\d+)\.0)/',
'ra32-wish-temp' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.4\.((\d+)\.4\.1\.2\.0)/',
);
$data = snmp_walk($device, '.1.3.6.1.4.1.20916.1', '-OQn');
foreach (explode(PHP_EOL, $data) as $line) {
list($oid, $value) = explode(' = ', $line);
$processed = false;
foreach ($virtual_tables as $vt_name => $vt_regex) {
if (preg_match($vt_regex, $oid, $matches)) {
$index = $matches[1];
$id = $matches[2];
$pre_cache[$vt_name][$index] = array(
'value' => $value,
'id' => $id,
);
$processed = true;
break; // skip rest
}
}
if (!$processed) {
$pre_cache[$oid] = array($value);
}
}
unset($data);