newdevice: APC Environmental monitoring units #5140

This commit is contained in:
Neil Lathwood
2017-01-18 08:48:33 +00:00
committed by GitHub
parent 84dca9435e
commit 8557f2df41
14 changed files with 249 additions and 1 deletions

View File

@@ -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';
}