From 424ce8f700d877c6c36156321890a7479541b350 Mon Sep 17 00:00:00 2001 From: Elizaveta Eremina <70374721+lizaerem@users.noreply.github.com> Date: Fri, 21 Jul 2023 12:31:44 +0300 Subject: [PATCH] Add profile for server-iron-switch (#15329) --- .../default_profiles/server-iron-switch.yaml | 13 +++++ .../compose/data/server-iron-switch.snmprec | 19 ++++++ .../test_profile_server_iron_switch.py | 58 +++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 snmp/datadog_checks/snmp/data/default_profiles/server-iron-switch.yaml create mode 100644 snmp/tests/compose/data/server-iron-switch.snmprec create mode 100644 snmp/tests/test_e2e_core_profiles/test_profile_server_iron_switch.py diff --git a/snmp/datadog_checks/snmp/data/default_profiles/server-iron-switch.yaml b/snmp/datadog_checks/snmp/data/default_profiles/server-iron-switch.yaml new file mode 100644 index 0000000000000..80dfb4961c5a8 --- /dev/null +++ b/snmp/datadog_checks/snmp/data/default_profiles/server-iron-switch.yaml @@ -0,0 +1,13 @@ +extends: + - _base.yaml + - _generic-host-resources-base.yaml + - _generic-if.yaml + +metadata: + device: + fields: + vendor: + value: "server_iron" + +sysobjectid: + - 1.3.6.1.4.1.1991.1.3.3.2 # Server Iron XL switches diff --git a/snmp/tests/compose/data/server-iron-switch.snmprec b/snmp/tests/compose/data/server-iron-switch.snmprec new file mode 100644 index 0000000000000..03349b834c199 --- /dev/null +++ b/snmp/tests/compose/data/server-iron-switch.snmprec @@ -0,0 +1,19 @@ +1.3.6.1.2.1.1.1.0|4|server-iron-switch Device Description +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.1991.1.3.3.2 +1.3.6.1.2.1.1.5.0|4|server-iron-switch.device.name +1.3.6.1.2.1.2.1.0|2|28 +1.3.6.1.2.1.25.1.1.0|67|201526890 +1.3.6.1.2.1.25.2.3.1.1.4|2|4 +1.3.6.1.2.1.25.2.3.1.1.31|2|31 +1.3.6.1.2.1.25.2.3.1.2.4|6|1.3.6.1.3.167.36 +1.3.6.1.2.1.25.2.3.1.2.31|6|1.3.6.1.3 +1.3.6.1.2.1.25.2.3.1.3.4|4x|6b65707420627574207468656972204a61646564206275742064726976696e67 +1.3.6.1.2.1.25.2.3.1.3.31|4x|7a6f6d62696573206f78656e206b657074204a6164656420717561696e746c79207a6f6d62696573 +1.3.6.1.2.1.25.2.3.1.5.4|2|17 +1.3.6.1.2.1.25.2.3.1.5.31|2|21 +1.3.6.1.2.1.25.2.3.1.6.4|2|30 +1.3.6.1.2.1.25.2.3.1.6.31|2|4 +1.3.6.1.2.1.25.3.3.1.1.10|2|10 +1.3.6.1.2.1.25.3.3.1.1.21|2|21 +1.3.6.1.2.1.25.3.3.1.2.10|2|31 +1.3.6.1.2.1.25.3.3.1.2.21|2|15 diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_server_iron_switch.py b/snmp/tests/test_e2e_core_profiles/test_profile_server_iron_switch.py new file mode 100644 index 0000000000000..f1ea1cfd71cc4 --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_server_iron_switch.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 datadog_checks.dev.utils import get_metadata_metrics + +from .. import common +from ..test_e2e_core_metadata import assert_device_metadata +from .utils import ( + assert_common_metrics, + assert_extend_generic_host_resources_base, + 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_server_iron_switch(dd_agent_check): + config = create_e2e_core_test_config('server-iron-switch') + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + 'snmp_profile:server-iron-switch', + 'snmp_host:server-iron-switch.device.name', + 'device_namespace:default', + 'snmp_device:' + ip_address, + ] + [] + + # --- TEST EXTENDED METRICS --- + assert_extend_generic_host_resources_base(aggregator, common_tags) + assert_extend_generic_if(aggregator, common_tags) + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + + # --- TEST METADATA --- + device = { + 'description': 'server-iron-switch Device Description', + 'id': 'default:' + ip_address, + 'id_tags': ['device_namespace:default', 'snmp_device:' + ip_address], + 'ip_address': '' + ip_address, + 'name': 'server-iron-switch.device.name', + 'profile': 'server-iron-switch', + 'status': 1, + 'sys_object_id': '1.3.6.1.4.1.1991.1.3.3.2', + 'vendor': 'server_iron', + } + device['tags'] = common_tags + assert_device_metadata(aggregator, device) + + # --- CHECK COVERAGE --- + aggregator.assert_all_metrics_covered() + aggregator.assert_metrics_using_metadata(get_metadata_metrics())