//.1.3.6.1.4.1.32050.2.1.27.5.0 = 303 //.1.3.6.1.4.1.32050.2.1.27.5.1 = -8 //.1.3.6.1.4.1.32050.2.1.27.5.2 = 529 //.1.3.6.1.4.1.32050.2.1.27.5.3 = 531 //.1.3.6.1.4.1.32050.2.1.27.5.4 = 0 //.1.3.6.1.4.1.32050.2.1.27.5.5 = 1000 //.1.3.6.1.4.1.32050.2.1.27.5.6 = -1000 //.1.3.6.1.4.1.32050.2.1.27.6.0 = 0 //.1.3.6.1.4.1.32050.2.1.27.6.1 = 0 //.1.3.6.1.4.1.32050.2.1.27.6.2 = 0 //.1.3.6.1.4.1.32050.2.1.27.6.3 = 0 //.1.3.6.1.4.1.32050.2.1.27.6.4 = 0 //.1.3.6.1.4.1.32050.2.1.27.6.5 = 1000 //.1.3.6.1.4.1.32050.2.1.27.6.6 = -1000 $index_analog = '.1.3.6.1.4.1.32050.2.1.27'; $packetflux_analog = snmpwalk_numericoids($device, $index_analog, array(), 'SNMPv2', mib_dirs()); $oids_analog[0] = array('class' => 'temperature', 'divisor' => 10); $oids_analog[1] = array('class' => 'voltage', 'divisor' => 10000); $oids_analog[2] = array('class' => 'voltage', 'divisor' => 10); $oids_analog[3] = array('class' => 'voltage', 'divisor' => 10); $oids_analog[4] = array('class' => 'current', 'divisor' => 1000); $oids_analog[5] = array('class' => 'temperature', 'divisor' => 10); // What is this? $oids_analog[6] = array('class' => 'temperature', 'divisor' => 10); // What is this? foreach ($oids_analog as $index => $entry) { $oid = "{$index_analog}.5.{$index}"; if (is_numeric($packetflux_analog[$oid])) { list($descr) = explode(' (', $packetflux_analog["{$index_analog}.2.{$index}"]); $class = $oids_analog[$index]['class']; $divisor = $oids_analog[$index]['divisor'];
/* Observium Network Management and Monitoring System * * @package observium * @subpackage poller * @copyright (C) 2006-2014 Adam Armstrong * */ global $graphs; if (dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `sensor_deleted` = ?;', array($device['device_id'], '0')) > 0) { echo '传感器: ' . PHP_EOL; // Cache data for use by polling modules foreach (dbFetchRows("SELECT `sensor_type` FROM `sensors` WHERE `device_id` = ? AND `poller_type` = 'snmp' AND `sensor_deleted` = '0' GROUP BY `sensor_type`", array($device['device_id'])) as $s_type) { if (is_array($config['sensor']['cache_oids'][$s_type['sensor_type']])) { echo '缓存中: ' . $s_type['sensor_type'] . ' '; foreach ($config['sensor']['cache_oids'][$s_type['sensor_type']] as $oid_to_cache) { if (!$oids_cached[$oid_to_cache]) { echo $oid_to_cache . ' '; $oids_cached[$oid_to_cache] = TRUE; $oid_cache = snmpwalk_numericoids($device, $oid_to_cache, $oid_cache); $oids_cached[$oid_to_cache] = TRUE; } } echo PHP_EOL; } } // Call poll_sensor for each sensor type that we support. foreach ($config['sensor_types'] as $sensor_class => $sensor_class_data) { poll_sensor($device, $sensor_class, $sensor_class_data['symbol'], $oid_cache); } } // EOF