Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,060 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
219 changes: 219 additions & 0 deletions
219
tests/plugins/enrichment/generic/snmp/juniper/bgp/data/devicetype_location_results.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
{ | ||
"enrichment": [ | ||
{ | ||
"data": [ | ||
{ | ||
"127.0.0.1": { | ||
"metrics_groups": [ | ||
{ | ||
"dimensions": { | ||
"bgp_adjacency_subtype": { | ||
"value": "'unknown-bgp_adjacency_subtype'" | ||
}, | ||
"bgp_adjacency_type": { | ||
"value": "'unknown-bgp_adjacency_type'" | ||
}, | ||
"interface_alias": { | ||
"value": "interface_alias.$index" | ||
}, | ||
"interface_name": { | ||
"value": "interface_name.$index" | ||
}, | ||
"local_address": { | ||
"value": "local_address.$index" | ||
}, | ||
"peer_address": { | ||
"value": "peer_address.$index" | ||
}, | ||
"peer_external_connection": { | ||
"value": "'unknown-peer_external_connection'" | ||
}, | ||
"peer_local_as": { | ||
"value": "peer_local_as.$index" | ||
}, | ||
"peer_remote_as": { | ||
"value": "peer_remote_as.$index" | ||
} | ||
}, | ||
"group_name": "bgp_session", | ||
"metrics": { | ||
"interface_speed": { | ||
"metric_type": "gauge", | ||
"transform": "lambda x: x * 1000000", | ||
"value": "interface_speed.$index" | ||
}, | ||
"peer_in_updates": { | ||
"metric_type": "counter", | ||
"value": "peer_in_updates.$index" | ||
}, | ||
"peer_out_updates": { | ||
"metric_type": "counter", | ||
"value": "peer_out_updates.$index" | ||
}, | ||
"peer_session_established_time": { | ||
"metric_type": "gauge", | ||
"value": "peer_session_established_time.$index" | ||
}, | ||
"peer_session_transitions": { | ||
"metric_type": "gauge", | ||
"value": "peer_session_transitions.$index" | ||
}, | ||
"peer_state": { | ||
"metric_type": "gauge", | ||
"value": "peer_state.$index" | ||
}, | ||
"peer_status": { | ||
"metric_type": "gauge", | ||
"value": "peer_status.$index" | ||
}, | ||
"prefix_in_prefixes": { | ||
"metric_type": "gauge", | ||
"value": "prefix_in_prefixes.$index" | ||
}, | ||
"prefix_in_prefixes_accepted": { | ||
"metric_type": "gauge", | ||
"value": "prefix_in_prefixes_accepted.$index" | ||
}, | ||
"prefix_in_prefixes_active": { | ||
"metric_type": "gauge", | ||
"value": "prefix_in_prefixes_active.$index" | ||
}, | ||
"prefix_in_prefixes_rejected": { | ||
"metric_type": "gauge", | ||
"value": "prefix_in_prefixes_rejected.$index" | ||
} | ||
} | ||
} | ||
], | ||
"oids": { | ||
"interface_alias": { | ||
"method": "static", | ||
"values": { | ||
"0.1.44.144.154.142.1.42.7.240.144": "", | ||
"0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1": "" | ||
} | ||
}, | ||
"interface_name": { | ||
"method": "static", | ||
"values": { | ||
"0.1.44.144.154.142.1.42.7.240.144": "xe-1/0/10.0", | ||
"0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1": "xe-11/0/10.0" | ||
} | ||
}, | ||
"interface_speed": { | ||
"method": "static", | ||
"values": { | ||
"0.1.44.144.154.142.1.42.7.240.144": "10000", | ||
"0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1": "10000" | ||
} | ||
}, | ||
"local_address": { | ||
"method": "static", | ||
"values": { | ||
"0.1.44.144.154.142.1.42.7.240.144": "44.144.154.142", | ||
"0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1": "2303:792:11:504:2:372c:0:6" | ||
} | ||
}, | ||
"peer_address": { | ||
"method": "static", | ||
"values": { | ||
"0.1.44.144.154.142.1.42.7.240.144": "42.7.240.144", | ||
"0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1": "2131:7fa:4011:4:5000:2a:400:5001" | ||
} | ||
}, | ||
"peer_in_updates": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.6.1.1.1" | ||
}, | ||
"peer_index": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14" | ||
}, | ||
"peer_local_as": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.9" | ||
}, | ||
"peer_out_updates": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.6.1.1.2" | ||
}, | ||
"peer_remote_as": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13" | ||
}, | ||
"peer_session_established_time": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.4.1.1.1" | ||
}, | ||
"peer_session_transitions": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.6.1.1.5" | ||
}, | ||
"peer_state": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2" | ||
}, | ||
"peer_status": { | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.3" | ||
}, | ||
"prefix_in_prefixes": { | ||
"index_transform": { | ||
"154.1.1": "0.1.44.144.154.142.1.42.7.240.144", | ||
"223.2.1": "0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1" | ||
}, | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7" | ||
}, | ||
"prefix_in_prefixes_accepted": { | ||
"index_transform": { | ||
"154.1.1": "0.1.44.144.154.142.1.42.7.240.144", | ||
"223.2.1": "0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1" | ||
}, | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8" | ||
}, | ||
"prefix_in_prefixes_active": { | ||
"index_transform": { | ||
"154.1.1": "0.1.44.144.154.142.1.42.7.240.144", | ||
"223.2.1": "0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1" | ||
}, | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.6.2.1.11" | ||
}, | ||
"prefix_in_prefixes_rejected": { | ||
"index_transform": { | ||
"154.1.1": "0.1.44.144.154.142.1.42.7.240.144", | ||
"223.2.1": "0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1" | ||
}, | ||
"method": "bulk_walk", | ||
"oid": ".1.3.6.1.4.1.2636.5.1.1.2.6.2.1.9" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"metadata": { | ||
"_enrichment_group_creation_timestamp": 1512629517.03121, | ||
"_enrichment_ttl": 300, | ||
"_execute_frequency": 60 | ||
}, | ||
"namespace": "metrics" | ||
} | ||
], | ||
"enrichment_group_set_creation_timestamp": 1512629517.03121, | ||
"resource": { | ||
"resource_class": "network", | ||
"resource_creation_timestamp": 1512629517.03121, | ||
"resource_endpoint": "127.0.0.1", | ||
"resource_id": "test_id", | ||
"resource_metadata": { | ||
"_resource_ttl": "604800", | ||
"model": "model" | ||
}, | ||
"resource_plugin": "dummy", | ||
"resource_site": "test_site", | ||
"resource_subclass": "test_subclass", | ||
"resource_type": "test_type" | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/plugins/enrichment/generic/snmp/juniper/bgp/data/recording/devicetype_location.snmprec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
1.3.6.1.2.1.4.35.1.7.670.1.4.42.7.240.144|2|6 | ||
1.3.6.1.2.1.4.35.1.7.670.1.4.44.144.154.142|2|6 | ||
1.3.6.1.2.1.4.35.1.7.683.2.16.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|2|1 | ||
1.3.6.1.2.1.4.35.1.7.683.2.16.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6|2|1 | ||
1.3.6.1.2.1.31.1.1.1.1.670|4x|78652d312f302f31302e30 | ||
1.3.6.1.2.1.31.1.1.1.1.683|4x|78652d31312f302f31302e30 | ||
1.3.6.1.2.1.31.1.1.1.15.670|66|10000 | ||
1.3.6.1.2.1.31.1.1.1.15.683|66|10000 | ||
1.3.6.1.2.1.31.1.1.1.18.670|4| | ||
1.3.6.1.2.1.31.1.1.1.18.683|4| | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.1.44.144.154.142.1.42.7.240.144|2|6 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|2|6 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.3.0.1.44.144.154.142.1.42.7.240.144|2|2 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.3.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|2|2 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.9.0.1.44.144.154.142.1.42.7.240.144|66|17457 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.9.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|66|17457 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.11.0.1.44.144.154.142.1.42.7.240.144|4x|2A07F090 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.11.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|4x|213107fa401100045000002a04005001 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.1.44.144.154.142.1.42.7.240.144|66|63956 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|66|42 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14.0.1.44.144.154.142.1.42.7.240.144|66|154 | ||
1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|66|223 | ||
1.3.6.1.4.1.2636.5.1.1.2.4.1.1.1.0.1.44.144.154.142.1.42.7.240.144|66|7775535 | ||
1.3.6.1.4.1.2636.5.1.1.2.4.1.1.1.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|66|556929 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.1.1.1.0.1.44.144.154.142.1.42.7.240.144|65|126349 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.1.1.1.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|65|10 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.1.1.2.0.1.44.144.154.142.1.42.7.240.144|65|0 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.1.1.2.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|65|9 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.1.1.5.0.1.44.144.154.142.1.42.7.240.144|65|4 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.1.1.5.0.2.35.3.7.146.0.17.5.4.0.2.55.44.0.0.0.6.2.33.49.7.250.64.17.0.4.80.0.0.42.4.0.80.1|65|1 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.154.1.1|66|403 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.7.223.2.1|66|152 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8.154.1.1|66|0 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8.223.2.1|66|152 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.9.154.1.1|66|403 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.9.223.2.1|66|0 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.11.154.1.1|66|0 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.11.223.2.1|66|152 | ||
1.3.6.1.4.1.2636.5.1.1.2.6.2.1.12.397.1.1|66|55028 |
61 changes: 61 additions & 0 deletions
61
...enrichment/generic/snmp/juniper/bgp/test_plugin_enrichment_juniper_bgp_session_metrics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import unittest | ||
import os | ||
|
||
from yahoo_panoptes.plugins.enrichment.generic.snmp.juniper.bgp.plugin_enrichment_bgp_session_metrics import \ | ||
JuniperBGPInfoPluginEnrichmentMetrics | ||
|
||
from tests.plugins.helpers import setup_module_default, tear_down_module_default, \ | ||
SNMPEnrichmentPluginTestFramework | ||
from mock import * | ||
|
||
pwd = os.path.dirname(os.path.abspath(__file__)) | ||
mock_time = Mock() | ||
mock_time.return_value = 1512629517.03121 | ||
|
||
mock_total_single_ports_oid = Mock() | ||
mock_total_single_ports_oid.return_value = None | ||
|
||
mock_source_pools = Mock() | ||
mock_source_pools.return_value = None | ||
|
||
mock_routing_engines = Mock() | ||
mock_routing_engines.return_value = None | ||
|
||
|
||
def setUpModule(): | ||
return setup_module_default(plugin_pwd=pwd) | ||
|
||
|
||
def tearDownModule(): | ||
return tear_down_module_default() | ||
|
||
|
||
class TestPluginJuniperBGPDeviceMetricsEnrichment(SNMPEnrichmentPluginTestFramework, unittest.TestCase): | ||
""" | ||
Test Juniper BGP Metrics | ||
Note: | ||
44.144.154.142 | ||
42.7.240.144 | ||
2131:7fa:4011:4:5000:2a:400:5001 | ||
2303:792:11:504:2:372c:0:6 | ||
The above IP Addresses which are used in the snmprec file were randomly generated. | ||
Verizon Media is not associated with them. | ||
""" | ||
path = pwd | ||
results_data_file = 'devicetype_location_results.json' | ||
snmp_community = 'devicetype_location' | ||
plugin_conf = {'Core': {'name': 'Test Plugin', 'module': 'test_plugin'}, | ||
'main': {'execute_frequency': '60', 'enrichment_ttl': '300', | ||
'resource_filter': 'resource_class = "network" AND resource_type = "juniper"', | ||
'polling_frequency': '300', 'enrichment_schema_version': '0.2'}, | ||
'snmp': {'timeout': 5, 'retries': 2}, | ||
'enrichment': {'preload': 'self:metrics'}, | ||
'x509': {'x509_secured_requests': 0}, | ||
} | ||
plugin_class = JuniperBGPInfoPluginEnrichmentMetrics | ||
use_enrichment = False | ||
|
||
def test_polling_plugin_timeout(self): | ||
"""Test plugin raises error during timeout""" | ||
pass |
Empty file.
Oops, something went wrong.