mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	* fix: Refactor ipoman cache code to use pre-cache in sensors #5881 * added missing file
This commit is contained in:
		@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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'];
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								includes/discovery/sensors/pre-cache/ipoman.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								includes/discovery/sensors/pre-cache/ipoman.inc.php
									
									
									
									
									
										Normal 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');
 | 
			
		||||
@@ -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'];
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user