fix: Refactor ipoman cache code to use pre-cache in sensors #5881 (#5983)

* fix: Refactor ipoman cache code to use pre-cache in sensors #5881

* added missing file
This commit is contained in:
Neil Lathwood
2017-03-06 15:36:53 +00:00
committed by GitHub
parent 2a211e86dc
commit 198ec806b3
5 changed files with 13 additions and 42 deletions

View File

@@ -2,15 +2,6 @@
echo ' IPOMANII-MIB ';
if (!is_array($cache['ipoman'])) {
d_echo('outletConfigDesc ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('outletConfigLocation ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('inletConfigDesc ');
$cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $cache['ipoman'], 'IPOMANII-MIB');
}
$oids_in = array();
$oids_out = array();
@@ -27,7 +18,7 @@ if (is_array($oids_in)) {
foreach ($oids_in as $index => $entry) {
$cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.3.'.$index;
$divisor = 1000;
$descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index");
$descr = (trim($pre_cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($pre_cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index");
$current = ($entry['inletStatusCurrent'] / $divisor);
$high_limit = ($entry['inletConfigCurrentHigh'] / 10);
@@ -40,7 +31,7 @@ if (is_array($oids_out)) {
foreach ($oids_out as $index => $entry) {
$cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.3.'.$index;
$divisor = 1000;
$descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index");
$descr = (trim($pre_cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($pre_cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index");
$current = ($entry['outletStatusCurrent'] / $divisor);
$high_limit = ($entry['outletConfigCurrentHigh'] / 10);

View File

@@ -2,15 +2,6 @@
echo 'IPOMANII-MIB: ';
if (!is_array($cache['ipoman'])) {
d_echo('outletConfigDesc ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('outletConfigLocation ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('inletConfigDesc ');
$cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $cache['ipoman']['in'], 'IPOMANII-MIB');
}
$oids = array();
d_echo('inletConfigFrequencyHigh ');
@@ -24,7 +15,7 @@ if (is_array($oids)) {
foreach ($oids as $index => $entry) {
$freq_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.4.'.$index;
$divisor = 10;
$descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index");
$descr = (trim($pre_cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($pre_cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index");
$current = ($entry['inletStatusFrequency'] / 10);
$low_limit = $entry['inletConfigFrequencyLow'];
$high_limit = $entry['inletConfigFrequencyHigh'];

View File

@@ -2,16 +2,6 @@
echo ' IPOMANII-MIB ';
// Inlet Disabled due to the fact thats it's Kwh instead of just Watt
if (!is_array($cache['ipoman'])) {
d_echo('outletConfigDesc ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('outletConfigLocation ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB');
// echo("inletConfigDesc ");
// $cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, "inletConfigDesc", $cache['ipoman'], "IPOMANII-MIB");
}
// $oids_in = array();
$oids_out = array();
@@ -37,7 +27,7 @@ if (is_array($oids_out)) {
foreach ($oids_out as $index => $entry) {
$cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.5.'.$index;
$divisor = 10;
$descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index");
$descr = (trim($pre_cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($pre_cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index");
$power = ($entry['outletStatusWH'] / $divisor);
discover_sensor($valid['sensor'], 'power', $device, $cur_oid, '2.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', null, null, null, null, $power);

View File

@@ -0,0 +1,8 @@
<?php
d_echo('outletConfigDesc ');
$pre_cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $pre_cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('outletConfigLocation ');
$pre_cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $pre_cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('inletConfigDesc ');
$pre_cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $pre_cache['ipoman']['in'], 'IPOMANII-MIB');

View File

@@ -2,15 +2,6 @@
echo ' IPOMANII-MIB ';
if (!is_array($cache['ipoman'])) {
d_echo('outletConfigDesc ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigDesc', $cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('outletConfigLocation ');
$cache['ipoman']['out'] = snmpwalk_cache_multi_oid($device, 'outletConfigLocation', $cache['ipoman']['out'], 'IPOMANII-MIB');
d_echo('inletConfigDesc ');
$cache['ipoman']['in'] = snmpwalk_cache_multi_oid($device, 'inletConfigDesc', $cache['ipoman']['in'], 'IPOMANII-MIB');
}
$oids = array();
d_echo('inletConfigVoltageHigh ');
@@ -24,7 +15,7 @@ if (is_array($oids)) {
foreach ($oids as $index => $entry) {
$volt_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.2.'.$index;
$divisor = 10;
$descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index");
$descr = (trim($pre_cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($pre_cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index");
$current = ($entry['inletStatusVoltage'] / 10);
$low_limit = $entry['inletConfigVoltageLow'];
$high_limit = $entry['inletConfigVoltageHigh'];