From 89a3e0e2ce0bb378986fc341550d0757adedb99b Mon Sep 17 00:00:00 2001 From: NouhaManai Date: Wed, 21 Jun 2023 15:31:24 +0200 Subject: [PATCH] Add per vendor generic profiles (#14721) * add dell generic profile * add fortinet generic profile * add juniper generic profile * move vendor profiles to default-profiles * add test for cisco * add test for dell * add test for fortinet * add test for juniper * linter * linter --- .../snmp/data/default_profiles/cisco.yaml | 12 ++ .../snmp/data/default_profiles/dell.yaml | 15 +++ .../snmp/data/default_profiles/fortinet.yaml | 17 +++ .../snmp/data/default_profiles/juniper.yaml | 27 +++++ snmp/tests/compose/data/cisco.snmprec | 11 ++ snmp/tests/compose/data/dell.snmprec | 6 + .../compose/data/fortinet-appliance.snmprec | 4 + .../compose/data/fortinet-fortiswitch.snmprec | 4 + .../compose/data/juniper-variation.snmprec | 10 ++ snmp/tests/compose/data/juniper.snmprec | 10 ++ .../test_profile_cisco.py | 67 ++++++++++ .../test_profile_dell.py | 58 +++++++++ .../test_profile_fortinet.py | 92 ++++++++++++++ .../test_profile_juniper.py | 114 ++++++++++++++++++ snmp/tests/test_e2e_core_profiles/utils.py | 61 +++++++++- 15 files changed, 502 insertions(+), 6 deletions(-) create mode 100644 snmp/datadog_checks/snmp/data/default_profiles/cisco.yaml create mode 100644 snmp/datadog_checks/snmp/data/default_profiles/dell.yaml create mode 100644 snmp/datadog_checks/snmp/data/default_profiles/fortinet.yaml create mode 100644 snmp/datadog_checks/snmp/data/default_profiles/juniper.yaml create mode 100644 snmp/tests/compose/data/cisco.snmprec create mode 100644 snmp/tests/compose/data/dell.snmprec create mode 100644 snmp/tests/compose/data/fortinet-appliance.snmprec create mode 100644 snmp/tests/compose/data/fortinet-fortiswitch.snmprec create mode 100644 snmp/tests/compose/data/juniper-variation.snmprec create mode 100644 snmp/tests/compose/data/juniper.snmprec create mode 100644 snmp/tests/test_e2e_core_profiles/test_profile_cisco.py create mode 100644 snmp/tests/test_e2e_core_profiles/test_profile_dell.py create mode 100644 snmp/tests/test_e2e_core_profiles/test_profile_fortinet.py create mode 100644 snmp/tests/test_e2e_core_profiles/test_profile_juniper.py diff --git a/snmp/datadog_checks/snmp/data/default_profiles/cisco.yaml b/snmp/datadog_checks/snmp/data/default_profiles/cisco.yaml new file mode 100644 index 0000000000000..658d524fc4cab --- /dev/null +++ b/snmp/datadog_checks/snmp/data/default_profiles/cisco.yaml @@ -0,0 +1,12 @@ +# Profile for Cisco devices + +extends: + - _base_cisco.yaml + +metadata: + device: + fields: + vendor: + value: "cisco" + +sysobjectid: 1.3.6.1.4.1.9.1.* diff --git a/snmp/datadog_checks/snmp/data/default_profiles/dell.yaml b/snmp/datadog_checks/snmp/data/default_profiles/dell.yaml new file mode 100644 index 0000000000000..8b97bdaefa8fb --- /dev/null +++ b/snmp/datadog_checks/snmp/data/default_profiles/dell.yaml @@ -0,0 +1,15 @@ +# Profile for Dell devices + +extends: + - _base.yaml + - _generic-ip.yaml + - _generic-tcp.yaml + - _generic-udp.yaml + +metadata: + device: + fields: + vendor: + value: "dell" + +sysobjectid: 1.3.6.1.4.1.674.* diff --git a/snmp/datadog_checks/snmp/data/default_profiles/fortinet.yaml b/snmp/datadog_checks/snmp/data/default_profiles/fortinet.yaml new file mode 100644 index 0000000000000..95a4cffb075e0 --- /dev/null +++ b/snmp/datadog_checks/snmp/data/default_profiles/fortinet.yaml @@ -0,0 +1,17 @@ +# Profile for Fortinet devices +# For Fortinet FortiGate devices, a separate fortinet-fortigate profile is used + +extends: + - _base.yaml + - _generic-if.yaml + +metadata: + device: + fields: + vendor: + value: "fortinet" + +sysobjectid: + - 1.3.6.1.4.1.12356.103.* # Fortinet Appliance + - 1.3.6.1.4.1.12356.106.1.* # Fortinet fortiswitch + \ No newline at end of file diff --git a/snmp/datadog_checks/snmp/data/default_profiles/juniper.yaml b/snmp/datadog_checks/snmp/data/default_profiles/juniper.yaml new file mode 100644 index 0000000000000..230ba49919c9f --- /dev/null +++ b/snmp/datadog_checks/snmp/data/default_profiles/juniper.yaml @@ -0,0 +1,27 @@ +# Profile for Juniper devices + +extends: + - _base.yaml + - _generic-if.yaml + - _generic-ip.yaml + - _generic-tcp.yaml + - _generic-udp.yaml + - _generic-bgp4.yaml + - _generic-ospf.yaml + - _generic-host-resources.yaml + - _juniper-junos-generic.yaml + +metadata: + device: + fields: + vendor: + value: "juniper-networks" + +# Juniper Products are declared in JUNIPER-CHASSIS-DEFINES-MIB. +# Products are defined under 1.3.6.1.4.1.2636.1.1.1.2 (jnxProductName). +# Variations are defined under 1.3.6.1.4.1.2636.1.1.1.4 (jnxProductVariation). +# Reference: https://mibs.observium.org/mib/JUNIPER-CHASSIS-DEFINES-MIB/ +sysobjectid: + - 1.3.6.1.4.1.2636.1.1.1.2.* # Products + - 1.3.6.1.4.1.2636.1.1.1.4.* # Variations + \ No newline at end of file diff --git a/snmp/tests/compose/data/cisco.snmprec b/snmp/tests/compose/data/cisco.snmprec new file mode 100644 index 0000000000000..d8dc87680a17d --- /dev/null +++ b/snmp/tests/compose/data/cisco.snmprec @@ -0,0 +1,11 @@ +1.3.6.1.2.1.1.1.0|4|Cisco IOS XR Software, Copyright (c) 2013-2020 by Cisco Systems, Inc. +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.122 +1.3.6.1.2.1.1.5.0|4|cisco3620 +1.3.6.1.2.1.2.1.0|2|4 +1.3.6.1.2.1.4.31.1.1.4.1|2|310637142 +1.3.6.1.2.1.6.5.0|65|457790 +1.3.6.1.2.1.7.8.0|70|6116206687099577350 +1.3.6.1.2.1.14.10.1.6.192.29.116.26.0|2|8 +1.3.6.1.2.1.15.3.1.3.244.12.239.177|2|2 +1.3.6.1.4.1.9.9.48.1.1.1.5.18|66|4078680985 +1.3.6.1.4.1.9.9.109.1.1.1.1.7.712|66|20 diff --git a/snmp/tests/compose/data/dell.snmprec b/snmp/tests/compose/data/dell.snmprec new file mode 100644 index 0000000000000..2384c2e6c2701 --- /dev/null +++ b/snmp/tests/compose/data/dell.snmprec @@ -0,0 +1,6 @@ +1.3.6.1.2.1.1.1.0|4|Dell dummy device +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.674.1 +1.3.6.1.2.1.1.5.0|4|dell.example +1.3.6.1.2.1.4.31.1.1.4.1|2|310637142 +1.3.6.1.2.1.6.5.0|65|457790 +1.3.6.1.2.1.7.8.0|70|6116206687099577350 diff --git a/snmp/tests/compose/data/fortinet-appliance.snmprec b/snmp/tests/compose/data/fortinet-appliance.snmprec new file mode 100644 index 0000000000000..e347175be93f0 --- /dev/null +++ b/snmp/tests/compose/data/fortinet-appliance.snmprec @@ -0,0 +1,4 @@ +1.3.6.1.2.1.1.1.0|4|Fortinet Appliance dummy device +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.12356.103.1 +1.3.6.1.2.1.1.5.0|4|fortinet.appliance.example +1.3.6.1.2.1.2.1.0|2|4 diff --git a/snmp/tests/compose/data/fortinet-fortiswitch.snmprec b/snmp/tests/compose/data/fortinet-fortiswitch.snmprec new file mode 100644 index 0000000000000..85e572bb6cedd --- /dev/null +++ b/snmp/tests/compose/data/fortinet-fortiswitch.snmprec @@ -0,0 +1,4 @@ +1.3.6.1.2.1.1.1.0|4|Fortinet Fortiswitch dummy device +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.12356.106.1.1 +1.3.6.1.2.1.1.5.0|4|fortinet.fortiswitch.example +1.3.6.1.2.1.2.1.0|2|4 diff --git a/snmp/tests/compose/data/juniper-variation.snmprec b/snmp/tests/compose/data/juniper-variation.snmprec new file mode 100644 index 0000000000000..03d44e5bde619 --- /dev/null +++ b/snmp/tests/compose/data/juniper-variation.snmprec @@ -0,0 +1,10 @@ +1.3.6.1.2.1.1.1.0|4|Juniper Networks, Inc. +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.2636.1.1.1.4.1 +1.3.6.1.2.1.1.5.0|4|jnxVariationM40 +1.3.6.1.2.1.2.1.0|2|4 +1.3.6.1.2.1.4.31.1.1.4.1|2|310637142 +1.3.6.1.2.1.6.5.0|65|457790 +1.3.6.1.2.1.7.8.0|70|6116206687099577350 +1.3.6.1.2.1.14.10.1.6.192.29.116.26.0|2|8 +1.3.6.1.2.1.15.3.1.3.244.12.239.177|2|2 +1.3.6.1.2.1.25.1.1.0|67|803137913 diff --git a/snmp/tests/compose/data/juniper.snmprec b/snmp/tests/compose/data/juniper.snmprec new file mode 100644 index 0000000000000..07ba8feead8b6 --- /dev/null +++ b/snmp/tests/compose/data/juniper.snmprec @@ -0,0 +1,10 @@ +1.3.6.1.2.1.1.1.0|4|Juniper Networks, Inc. +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.2636.1.1.1.2.1 +1.3.6.1.2.1.1.5.0|4|jnxM40 +1.3.6.1.2.1.2.1.0|2|4 +1.3.6.1.2.1.4.31.1.1.4.1|2|310637142 +1.3.6.1.2.1.6.5.0|65|457790 +1.3.6.1.2.1.7.8.0|70|6116206687099577350 +1.3.6.1.2.1.14.10.1.6.192.29.116.26.0|2|8 +1.3.6.1.2.1.15.3.1.3.244.12.239.177|2|2 +1.3.6.1.2.1.25.1.1.0|67|803137913 diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_cisco.py b/snmp/tests/test_e2e_core_profiles/test_profile_cisco.py new file mode 100644 index 0000000000000..9475e3027a469 --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_cisco.py @@ -0,0 +1,67 @@ +# (C) Datadog, Inc. 2023-present +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) + +import pytest + +from .. import common +from ..test_e2e_core_metadata import assert_device_metadata +from .utils import ( + assert_common_metrics, + assert_extend_cisco_cpu_memory, + assert_extend_generic_bgp4, + assert_extend_generic_if, + assert_extend_generic_ip, + assert_extend_generic_ospf, + assert_extend_generic_tcp, + assert_extend_generic_udp, + create_e2e_core_test_config, + get_device_ip_from_config, +) + +pytestmark = [pytest.mark.e2e, common.py3_plus_only, common.snmp_integration_only] + + +def test_e2e_profile_cisco(dd_agent_check): + config = create_e2e_core_test_config("cisco") + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + "snmp_profile:cisco", + "snmp_host:cisco3620", + "device_namespace:default", + "snmp_device:" + ip_address, + ] + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + assert_extend_generic_if(aggregator, common_tags) + assert_extend_generic_ip(aggregator, common_tags) + assert_extend_generic_tcp(aggregator, common_tags) + assert_extend_generic_udp(aggregator, common_tags) + assert_extend_generic_ospf(aggregator, common_tags) + assert_extend_generic_bgp4(aggregator, common_tags) + assert_extend_cisco_cpu_memory(aggregator, common_tags) + aggregator.assert_all_metrics_covered() + + # --- TEST METADATA --- + device = { + "description": "Cisco IOS XR Software, Copyright (c) 2013-2020 by Cisco Systems, Inc.", + "id": "default:" + ip_address, + "id_tags": ["device_namespace:default", "snmp_device:" + ip_address], + "ip_address": "" + ip_address, + "name": "cisco3620", + "os_name": "IOSXR", + "profile": "cisco", + "status": 1, + "sys_object_id": "1.3.6.1.4.1.9.1.122", + "tags": [ + "device_namespace:default", + "snmp_device:" + ip_address, + "snmp_host:cisco3620", + "snmp_profile:cisco", + ], + "vendor": "cisco", + } + assert_device_metadata(aggregator, device) diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_dell.py b/snmp/tests/test_e2e_core_profiles/test_profile_dell.py new file mode 100644 index 0000000000000..dc69ad3c3f511 --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_dell.py @@ -0,0 +1,58 @@ +# (C) Datadog, Inc. 2023-present +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) + +import pytest + +from .. import common +from ..test_e2e_core_metadata import assert_device_metadata +from .utils import ( + assert_common_metrics, + assert_extend_generic_ip, + assert_extend_generic_tcp, + assert_extend_generic_udp, + create_e2e_core_test_config, + get_device_ip_from_config, +) + +pytestmark = [pytest.mark.e2e, common.py3_plus_only, common.snmp_integration_only] + + +def test_e2e_profile_dell(dd_agent_check): + config = create_e2e_core_test_config("dell") + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + "snmp_profile:dell", + "snmp_host:dell.example", + "device_namespace:default", + "snmp_device:" + ip_address, + ] + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + assert_extend_generic_ip(aggregator, common_tags) + assert_extend_generic_tcp(aggregator, common_tags) + assert_extend_generic_udp(aggregator, common_tags) + aggregator.assert_all_metrics_covered() + + # --- TEST METADATA --- + device = { + "description": "Dell dummy device", + "id": "default:" + ip_address, + "id_tags": ["device_namespace:default", "snmp_device:" + ip_address], + "ip_address": "" + ip_address, + "name": "dell.example", + "profile": "dell", + "status": 1, + "sys_object_id": "1.3.6.1.4.1.674.1", + "tags": [ + "device_namespace:default", + "snmp_device:" + ip_address, + "snmp_host:dell.example", + "snmp_profile:dell", + ], + "vendor": "dell", + } + assert_device_metadata(aggregator, device) diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_fortinet.py b/snmp/tests/test_e2e_core_profiles/test_profile_fortinet.py new file mode 100644 index 0000000000000..05c92fab41fae --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_fortinet.py @@ -0,0 +1,92 @@ +# (C) Datadog, Inc. 2023-present +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) + +import pytest + +from .. import common +from ..test_e2e_core_metadata import assert_device_metadata +from .utils import ( + assert_common_metrics, + assert_extend_generic_if, + create_e2e_core_test_config, + get_device_ip_from_config, +) + +pytestmark = [pytest.mark.e2e, common.py3_plus_only, common.snmp_integration_only] + + +def test_e2e_profile_fortinet_appliance(dd_agent_check): + config = create_e2e_core_test_config("fortinet-appliance") + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + "snmp_profile:fortinet", + "snmp_host:fortinet.appliance.example", + "device_namespace:default", + "snmp_device:" + ip_address, + ] + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + assert_extend_generic_if(aggregator, common_tags) + aggregator.assert_all_metrics_covered() + + # --- TEST METADATA --- + device = { + "description": "Fortinet Appliance dummy device", + "id": "default:" + ip_address, + "id_tags": ["device_namespace:default", "snmp_device:" + ip_address], + "ip_address": "" + ip_address, + "name": "fortinet.appliance.example", + "profile": "fortinet", + "status": 1, + "sys_object_id": "1.3.6.1.4.1.12356.103.1", + "tags": [ + "device_namespace:default", + "snmp_device:" + ip_address, + "snmp_host:fortinet.appliance.example", + "snmp_profile:fortinet", + ], + "vendor": "fortinet", + } + assert_device_metadata(aggregator, device) + + +def test_e2e_profile_fortinet_fortiswitch(dd_agent_check): + config = create_e2e_core_test_config("fortinet-fortiswitch") + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + "snmp_profile:fortinet", + "snmp_host:fortinet.fortiswitch.example", + "device_namespace:default", + "snmp_device:" + ip_address, + ] + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + assert_extend_generic_if(aggregator, common_tags) + aggregator.assert_all_metrics_covered() + + # --- TEST METADATA --- + device = { + "description": "Fortinet Fortiswitch dummy device", + "id": "default:" + ip_address, + "id_tags": ["device_namespace:default", "snmp_device:" + ip_address], + "ip_address": "" + ip_address, + "name": "fortinet.fortiswitch.example", + "profile": "fortinet", + "status": 1, + "sys_object_id": "1.3.6.1.4.1.12356.106.1.1", + "tags": [ + "device_namespace:default", + "snmp_device:" + ip_address, + "snmp_host:fortinet.fortiswitch.example", + "snmp_profile:fortinet", + ], + "vendor": "fortinet", + } + assert_device_metadata(aggregator, device) diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_juniper.py b/snmp/tests/test_e2e_core_profiles/test_profile_juniper.py new file mode 100644 index 0000000000000..ce91289b121b9 --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_juniper.py @@ -0,0 +1,114 @@ +# (C) Datadog, Inc. 2023-present +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) + +import pytest + +from .. import common +from ..test_e2e_core_metadata import assert_device_metadata +from .utils import ( + assert_common_metrics, + assert_extend_generic_bgp4, + assert_extend_generic_host_resources, + assert_extend_generic_if, + assert_extend_generic_ip, + assert_extend_generic_ospf, + assert_extend_generic_tcp, + assert_extend_generic_udp, + create_e2e_core_test_config, + get_device_ip_from_config, +) + +pytestmark = [pytest.mark.e2e, common.py3_plus_only, common.snmp_integration_only] + + +def test_e2e_profile_juniper(dd_agent_check): + config = create_e2e_core_test_config("juniper") + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + "snmp_profile:juniper", + "snmp_host:jnxM40", + "device_namespace:default", + "snmp_device:" + ip_address, + ] + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + assert_extend_generic_if(aggregator, common_tags) + assert_extend_generic_ip(aggregator, common_tags) + assert_extend_generic_tcp(aggregator, common_tags) + assert_extend_generic_udp(aggregator, common_tags) + assert_extend_generic_ospf(aggregator, common_tags) + assert_extend_generic_bgp4(aggregator, common_tags) + assert_extend_generic_host_resources(aggregator, common_tags) + + aggregator.assert_all_metrics_covered() + + # --- TEST METADATA --- + device = { + "description": "Juniper Networks, Inc.", + "id": "default:" + ip_address, + "id_tags": ["device_namespace:default", "snmp_device:" + ip_address], + "ip_address": "" + ip_address, + "name": "jnxM40", + 'os_name': 'JUNOS', + "profile": "juniper", + "status": 1, + "sys_object_id": "1.3.6.1.4.1.2636.1.1.1.2.1", + "tags": [ + "device_namespace:default", + "snmp_device:" + ip_address, + "snmp_host:jnxM40", + "snmp_profile:juniper", + ], + "vendor": "juniper-networks", + } + assert_device_metadata(aggregator, device) + + +def test_e2e_profile_juniper_variation(dd_agent_check): + config = create_e2e_core_test_config("juniper-variation") + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + "snmp_profile:juniper", + "snmp_host:jnxVariationM40", + "device_namespace:default", + "snmp_device:" + ip_address, + ] + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + assert_extend_generic_if(aggregator, common_tags) + assert_extend_generic_ip(aggregator, common_tags) + assert_extend_generic_tcp(aggregator, common_tags) + assert_extend_generic_udp(aggregator, common_tags) + assert_extend_generic_ospf(aggregator, common_tags) + assert_extend_generic_bgp4(aggregator, common_tags) + assert_extend_generic_host_resources(aggregator, common_tags) + + aggregator.assert_all_metrics_covered() + + # --- TEST METADATA --- + device = { + "description": "Juniper Networks, Inc.", + "id": "default:" + ip_address, + "id_tags": ["device_namespace:default", "snmp_device:" + ip_address], + "ip_address": "" + ip_address, + "name": "jnxVariationM40", + 'os_name': 'JUNOS', + "profile": "juniper", + "status": 1, + "sys_object_id": "1.3.6.1.4.1.2636.1.1.1.4.1", + "tags": [ + "device_namespace:default", + "snmp_device:" + ip_address, + "snmp_host:jnxVariationM40", + "snmp_profile:juniper", + ], + "vendor": "juniper-networks", + } + assert_device_metadata(aggregator, device) diff --git a/snmp/tests/test_e2e_core_profiles/utils.py b/snmp/tests/test_e2e_core_profiles/utils.py index ab1d0e2cd900c..c5d937fb136ab 100644 --- a/snmp/tests/test_e2e_core_profiles/utils.py +++ b/snmp/tests/test_e2e_core_profiles/utils.py @@ -11,19 +11,68 @@ def create_e2e_core_test_config(community_string): It is used to tell snmpsim to use the corresponding .snmprec file. """ config = common.generate_container_instance_config([]) - config['init_config']['loader'] = 'core' - instance = config['instances'][0] - instance.update({'community_string': community_string}) + config["init_config"]["loader"] = "core" + instance = config["instances"][0] + instance.update({"community_string": community_string}) return config def get_device_ip_from_config(config): - return config['instances'][0]['ip_address'] + return config["instances"][0]["ip_address"] def assert_common_metrics(aggregator, common_tags): - common.assert_common_metrics(aggregator, tags=common_tags, is_e2e=True, loader='core') + common.assert_common_metrics(aggregator, tags=common_tags, is_e2e=True, loader="core") def assert_extend_generic_if(aggregator, common_tags): - aggregator.assert_metric('snmp.ifNumber', metric_type=aggregator.GAUGE, tags=common_tags) + aggregator.assert_metric("snmp.ifNumber", metric_type=aggregator.GAUGE, tags=common_tags) + + +def assert_extend_generic_ip(aggregator, common_tags): + aggregator.assert_metric( + "snmp.ipSystemStatsHCInReceives", + metric_type=aggregator.COUNT, + tags=common_tags + ["ipversion:ipv4"], + ) + + +def assert_extend_generic_tcp(aggregator, common_tags): + aggregator.assert_metric("snmp.tcpActiveOpens", metric_type=aggregator.COUNT, tags=common_tags) + + +def assert_extend_generic_udp(aggregator, common_tags): + aggregator.assert_metric("snmp.udpHCInDatagrams", metric_type=aggregator.COUNT, tags=common_tags) + + +def assert_extend_generic_ospf(aggregator, common_tags): + aggregator.assert_metric("snmp.ospfNbrState", metric_type=aggregator.GAUGE, tags=common_tags) + + +def assert_extend_generic_bgp4(aggregator, common_tags): + aggregator.assert_metric( + "snmp.bgpPeerAdminStatus", + metric_type=aggregator.GAUGE, + tags=common_tags + ["admin_status:start"], + ) + aggregator.assert_metric( + "snmp.peerConnectionByState", + metric_type=aggregator.GAUGE, + tags=common_tags + ["admin_status:start"], + value=1, + ) + + +def assert_extend_cisco_cpu_memory(aggregator, common_tags): + aggregator.assert_metric("snmp.memory.used", metric_type=aggregator.GAUGE, tags=common_tags + ["mem:18"]) + aggregator.assert_metric("snmp.ciscoMemoryPoolUsed", metric_type=aggregator.GAUGE, tags=common_tags) + aggregator.assert_metric("snmp.cpu.usage", metric_type=aggregator.GAUGE, tags=common_tags + ["cpu:712"]) + aggregator.assert_metric( + "snmp.cpmCPUTotal1minRev", + metric_type=aggregator.GAUGE, + tags=common_tags + ["cpu:712"], + ) + + +def assert_extend_generic_host_resources(aggregator, common_tags): + aggregator.assert_metric("snmp.hrSystemUptime", metric_type=aggregator.GAUGE, tags=common_tags)