mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	more flexibility for divisor value
This commit is contained in:
		| @@ -878,16 +878,23 @@ function avtech_add_sensor($device, $sensor) | ||||
|  * @param $device | ||||
|  * @param $serial | ||||
|  * @param $divisor | ||||
|  * @param $sensor | ||||
|  * @return int | ||||
|  */ | ||||
| function get_device_divisor($device, $serial, $divisor) | ||||
| function get_device_divisor($device, $serial, $divisor, $sensor) | ||||
| { | ||||
|     if ($device['os'] == 'poweralert') { | ||||
|     if (($device['os'] == 'poweralert') && ($sensor == 'current' || $sensor == 'frequencies' || $sensor == 'voltages')) { | ||||
|         if (version_compare($serial, '12.06.0068', '>=')) { | ||||
|             $divisor = 10; | ||||
|         } elseif (version_compare($serial, '12.04.0055', '>=')) { | ||||
|             $divisor = 1; | ||||
|         } | ||||
|     } elseif (($device['os'] == 'huaweiups') && ($sensor == 'frequencies')) { | ||||
|         $divisor = 100; | ||||
|     } elseif (($device['os'] == 'netmanplus') && ($sensor == 'voltages')) { | ||||
|         $divisor = 1; | ||||
|     } else { | ||||
|         $divisor = 10; | ||||
|     } | ||||
|     return $divisor; | ||||
| } | ||||
|   | ||||
| @@ -1,9 +1,6 @@ | ||||
| <?php | ||||
|  | ||||
| $divisor = 10; | ||||
| if ($device['os'] == 'poweralert') { | ||||
|     $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
| } | ||||
| $divisor = get_device_divisor($device, $_tmp_serial, $divisor, "current"); | ||||
|  | ||||
| // RFC1628 UPS | ||||
| if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']]) { | ||||
|   | ||||
| @@ -17,13 +17,8 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul | ||||
|  | ||||
|         $current = (snmp_get($device, $freq_oid, '-Oqv') / 10); | ||||
|         $type    = 'rfc1628'; | ||||
|         $divisor = 10; | ||||
|         if ($device['os'] == 'huaweiups') { | ||||
|             $divisor = 100; | ||||
|         } | ||||
|         if ($device['os'] == 'poweralert') { | ||||
|             $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
|         } | ||||
|         $divisor = get_device_divisor($device, $_tmp_serial, $divisor, "frequencies"); | ||||
|  | ||||
|         $index = '3.2.0.'.$i; | ||||
|         discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); | ||||
|     } | ||||
| @@ -32,13 +27,8 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul | ||||
|     $descr    = 'Output'; | ||||
|     $current  = (snmp_get($device, $freq_oid, '-Oqv') / 10); | ||||
|     $type     = 'rfc1628'; | ||||
|     $divisor  = 10; | ||||
|     if ($device['os'] == 'huaweiups') { | ||||
|         $divisor = 100; | ||||
|     } | ||||
|     if ($device['os'] == 'poweralert') { | ||||
|         $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
|     } | ||||
|     $divisor = get_device_divisor($device, $_tmp_serial, $divisor, "frequencies"); | ||||
|  | ||||
|     $index = '4.2.0'; | ||||
|     discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); | ||||
|  | ||||
| @@ -46,13 +36,8 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul | ||||
|     $descr    = 'Bypass'; | ||||
|     $current  = (snmp_get($device, $freq_oid, '-Oqv') / 10); | ||||
|     $type     = 'rfc1628'; | ||||
|     $divisor  = 10; | ||||
|     if ($device['os'] == 'huaweiups') { | ||||
|         $divisor = 100; | ||||
|     } | ||||
|     if ($device['os'] == 'poweralert') { | ||||
|         $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
|     } | ||||
|     $divisor = get_device_divisor($device, $_tmp_serial, $divisor, "frequencies"); | ||||
|  | ||||
|     $index = '5.1.0'; | ||||
|     discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); | ||||
| }//end if | ||||
|   | ||||
| @@ -15,15 +15,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul | ||||
|             $split_oid        = explode('.', $oid); | ||||
|             $volt_id          = $split_oid[(count($split_oid) - 1)]; | ||||
|             $volt_oid         = "1.3.6.1.2.1.33.1.2.5.$volt_id"; | ||||
|             $divisor          = 10; | ||||
|  | ||||
|             if ($device['os'] == 'netmanplus') { | ||||
|                 $divisor = 1; | ||||
|             } | ||||
|  | ||||
|             if ($device['os'] == 'poweralert') { | ||||
|                 $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
|             } | ||||
|             $divisor = get_device_divisor($device, $_tmp_serial, $divisor, 'voltages'); | ||||
|  | ||||
|             $volt  = (snmp_get($device, $volt_oid, '-O vq') / $divisor); | ||||
|             $descr = 'Battery'.(count(explode("\n", $oids)) == 1 ? '' : ' '.($volt_id + 1)); | ||||
| @@ -46,15 +38,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul | ||||
|         } | ||||
|  | ||||
|         $type    = 'rfc1628'; | ||||
|         $divisor = 10; | ||||
|  | ||||
|         if ($device['os'] == 'netmanplus') { | ||||
|             $divisor = 1; | ||||
|         } | ||||
|  | ||||
|         if ($device['os'] == 'poweralert') { | ||||
|             $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
|         } | ||||
|         $divisor = get_device_divisor($device, $_tmp_serial, $divisor, 'voltages'); | ||||
|  | ||||
|         $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); | ||||
|         $index   = $i; | ||||
| @@ -74,16 +58,10 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul | ||||
|         } | ||||
|  | ||||
|         $type    = 'rfc1628'; | ||||
|         $divisor = 10; | ||||
|         if ($device['os'] == 'netmanplus') { | ||||
|             $divisor = 1; | ||||
|         } | ||||
|  | ||||
|         if ($device['os'] == 'poweralert') { | ||||
|             $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
|         } | ||||
|         $divisor = get_device_divisor($device, $_tmp_serial, $divisor, 'voltages'); | ||||
|  | ||||
|         $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); | ||||
|         $divisor = get_device_divisor($device, $_tmp_serial, $divisor, 'voltages'); | ||||
|         $index   = (100 + $i); | ||||
|  | ||||
|         discover_sensor($valid['sensor'], 'voltage', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); | ||||
| @@ -101,15 +79,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul | ||||
|         } | ||||
|  | ||||
|         $type    = 'rfc1628'; | ||||
|         $divisor = 10; | ||||
|  | ||||
|         if ($device['os'] == 'netmanplus') { | ||||
|             $divisor = 1; | ||||
|         } | ||||
|  | ||||
|         if ($device['os'] == 'poweralert') { | ||||
|             $divisor = get_device_divisor($device, $_tmp_serial, $divisor); | ||||
|         } | ||||
|         $divisor = get_device_divisor($device, $_tmp_serial, $divisor, 'voltages'); | ||||
|  | ||||
|         $current = (snmp_get($device, $volt_oid, '-Oqv') / $divisor); | ||||
|         $index   = (200 + $i); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user