mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Update IronWare sensors & bgp-peers discovery, allow skip_values to target a specific index appended to the OID (#10941)
* Migrate ironware sensor discovery from php to yaml. * More sensors, add grouping. * dynamic_discovery_get_value() becomes getValueFromData() * Target a specific index with skip_values. * Improve Brocade BGP session discovery/polling This commit allows for the correct discovery of BGP sessions with 32-bit ASNs, IPv6 neighbors using the BGP4V2-MIB which is based on draft-ietf-idr-bgp4-mibv2-11 and also polls for IPv4 unicast received routes through the FOUNDRY-SN-BGP4-GROUP-MIB. Copied most of the code from PR#8877 by @Mikeburke14, cleaned up the code a little bit to match the normal LibreNMS style, and fixed bgpPeers_cbgp discovery as well as polling for the ipv4.unicast neighbors. Note that older Brocade IronWare firmware versions are known to have multiple defects relating to the BGP4V2-MIB which might result in certain missing non-established neighbors. Related vendor defect numbers: - DEFECT000633962 -- Symptom: The OID bgp4V2PeerAdminStatus does not return the correct value -- Reported: NI 05.7.00 -- Resolved: NI 05.8.00g - DEFECT000583319 -- Symptom: SNMP polling on bgp4V2PeerTable (OID brcdIp.3.5.1.1.2) does not display all the BGP entries -- Reported: NI 05.6.00 -- Resolved: NI 05.8.00e - DEFECT000550309 -- Symptom: SNMP polling on bgp4V2PeerTable (OID brcdIp.3.5.1.1.2) does not display the full information -- Reported: NI 05.7.00 -- Resolved: NI 05.8.00c * Add ironware CER & ICX platform test data. * Re-add ironware.json compatible with current master branch.
This commit is contained in:
@@ -86,7 +86,7 @@ class YamlDiscovery
|
||||
$current_data[$name] = static::replaceValues($name, $index, $count, $data, $pre_cache);
|
||||
} else {
|
||||
// replace references to data
|
||||
$current_data[$name] = dynamic_discovery_get_value($name, $index, $data, $pre_cache, $value);
|
||||
$current_data[$name] = static::getValueFromData($name, $index, $data, $pre_cache, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class YamlDiscovery
|
||||
|
||||
public static function replaceValues($name, $index, $count, $data, $pre_cache)
|
||||
{
|
||||
$value = dynamic_discovery_get_value($name, $index, $data, $pre_cache);
|
||||
$value = static::getValueFromData($name, $index, $data, $pre_cache);
|
||||
if (is_null($value)) {
|
||||
// built in replacements
|
||||
$search = [
|
||||
@@ -130,7 +130,7 @@ class YamlDiscovery
|
||||
|
||||
// search discovery data for values
|
||||
$value = preg_replace_callback('/{{ \$([a-zA-Z0-9.]+) }}/', function ($matches) use ($index, $data, $pre_cache) {
|
||||
$replace = dynamic_discovery_get_value($matches[1], $index, $data, $pre_cache, null);
|
||||
$replace = static::getValueFromData($matches[1], $index, $data, $pre_cache, null);
|
||||
if (is_null($replace)) {
|
||||
d_echo('Warning: No variable available to replace ' . $matches[1] . ".\n");
|
||||
return ''; // remove the unavailable variable
|
||||
@@ -147,7 +147,7 @@ class YamlDiscovery
|
||||
* Helper function for dynamic discovery to search for data from pre_cached snmp data
|
||||
*
|
||||
* @param string $name The name of the field from the discovery data or just an oid
|
||||
* @param int $index The index of the current sensor
|
||||
* @param string $index The index of the current sensor
|
||||
* @param array $discovery_data The discovery data for the current sensor
|
||||
* @param array $pre_cache all pre-cached snmp data
|
||||
* @param mixed $default The default value to return if data is not found
|
||||
@@ -169,6 +169,8 @@ class YamlDiscovery
|
||||
return $pre_cache[$name][$index][$name];
|
||||
} elseif (isset($pre_cache[$index][$name])) {
|
||||
return $pre_cache[$index][$name];
|
||||
} elseif (isset($pre_cache[$name][$index])) {
|
||||
return $pre_cache[$name][$index];
|
||||
} elseif (count($pre_cache[$name]) === 1) {
|
||||
return current($pre_cache[$name]);
|
||||
}
|
||||
@@ -252,6 +254,10 @@ class YamlDiscovery
|
||||
// Dynamic skipping of data
|
||||
$op = isset($skip_value['op']) ? $skip_value['op'] : '!=';
|
||||
$tmp_value = static::getValueFromData($skip_value['oid'], $index, $yaml_item_data, $pre_cache);
|
||||
if (str_contains($skip_value['oid'], '.')) {
|
||||
list($skip_value['oid'], $targeted_index) = explode('.', $skip_value['oid'], 2);
|
||||
$tmp_value = static::getValueFromData($skip_value['oid'], $targeted_index, $yaml_item_data, $pre_cache);
|
||||
}
|
||||
if (compare_var($tmp_value, $skip_value['value'], $op)) {
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user