mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Allow num_oid to use OCTET STRING indexes (#10410)
* make index available as OCTET STRING converted to OID * codeclimate
This commit is contained in:
		@@ -85,7 +85,8 @@ The only sensor we have defined here is airflow. The available options are as fo
 | 
			
		||||
  the value. If not provided willuse `oid`
 | 
			
		||||
- `num_oid` (required): This is the numerical OID that contains
 | 
			
		||||
  `value`. This should always include `{{ $index }}`.  snmptranslate
 | 
			
		||||
  -On can help figure out the number
 | 
			
		||||
  -On can help figure out the number.
 | 
			
		||||
  In case the index is a string, `{{ $index_string }}` can be used instead.
 | 
			
		||||
- `divisor` (optional): This is the divisor to use against the returned `value`.
 | 
			
		||||
- `multiplier` (optional): This is the multiplier to use against the returned `value`.
 | 
			
		||||
- `low_limit` (optional): This is the critical low threshold that
 | 
			
		||||
 
 | 
			
		||||
@@ -1047,6 +1047,9 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
 | 
			
		||||
                $skippedFromYaml = YamlDiscovery::canSkipItem($value, $index, $data, $sensor_options, $pre_cache);
 | 
			
		||||
                if ($skippedFromYaml === false && is_numeric($value)) {
 | 
			
		||||
                    $oid = str_replace('{{ $index }}', $index, $data['num_oid']);
 | 
			
		||||
                    // if index is a string, we need to convert it to OID
 | 
			
		||||
                    // strlen($index) as first number, and each letter converted to a number, separated by dots
 | 
			
		||||
                    $oid = str_replace('{{ $index_string }}', strlen($index) . '.' . implode(".", unpack("c*", $index)), $oid);
 | 
			
		||||
 | 
			
		||||
                    // process the description
 | 
			
		||||
                    $descr = YamlDiscovery::replaceValues('descr', $index, null, $data, $pre_cache);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user