mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
newdevice: APC Environmental monitoring units #5140
This commit is contained in:
@@ -16,6 +16,19 @@ function bulk_sensor_snmpget($device, $sensors)
|
||||
return $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $device
|
||||
* @return array
|
||||
*/
|
||||
function sensor_precache($device)
|
||||
{
|
||||
$sensor_config = array();
|
||||
if (file_exists('includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php')) {
|
||||
include 'includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php';
|
||||
}
|
||||
return $sensor_config;
|
||||
}
|
||||
|
||||
function poll_sensor($device, $class, $unit)
|
||||
{
|
||||
global $config, $memcache, $agent_sensors;
|
||||
@@ -23,6 +36,7 @@ function poll_sensor($device, $class, $unit)
|
||||
$sensors = array();
|
||||
$misc_sensors = array();
|
||||
$all_sensors = array();
|
||||
|
||||
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ?', array($class, $device['device_id'])) as $sensor) {
|
||||
if ($sensor['poller_type'] == 'agent') {
|
||||
$misc_sensors[] = $sensor;
|
||||
@@ -35,6 +49,8 @@ function poll_sensor($device, $class, $unit)
|
||||
|
||||
$snmp_data = bulk_sensor_snmpget($device, $sensors);
|
||||
|
||||
$sensor_cache = sensor_precache($device);
|
||||
|
||||
foreach ($sensors as $sensor) {
|
||||
echo 'Checking (' . $sensor['poller_type'] . ") $class " . $sensor['sensor_descr'] . '... '.PHP_EOL;
|
||||
|
||||
@@ -44,7 +60,7 @@ function poll_sensor($device, $class, $unit)
|
||||
$sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid']]));
|
||||
|
||||
if (file_exists('includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php')) {
|
||||
require_once 'includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php';
|
||||
require 'includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php';
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user