From 51a37d607c67ddcde1cc3cc8d264c341e0f569b5 Mon Sep 17 00:00:00 2001 From: Alexandre Yang Date: Tue, 25 Jul 2023 18:34:35 +0200 Subject: [PATCH] Add profile linksys (#15372) * Add profile linksys * add metadata * add snmprec * add e2e test * fix style --- .../snmp/data/default_profiles/linksys.yaml | 10 ++++ snmp/tests/compose/data/linksys.snmprec | 4 ++ .../test_profile_linksys.py | 56 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 snmp/datadog_checks/snmp/data/default_profiles/linksys.yaml create mode 100644 snmp/tests/compose/data/linksys.snmprec create mode 100644 snmp/tests/test_e2e_core_profiles/test_profile_linksys.py diff --git a/snmp/datadog_checks/snmp/data/default_profiles/linksys.yaml b/snmp/datadog_checks/snmp/data/default_profiles/linksys.yaml new file mode 100644 index 0000000000000..9f591fee26659 --- /dev/null +++ b/snmp/datadog_checks/snmp/data/default_profiles/linksys.yaml @@ -0,0 +1,10 @@ +extends: + - _base.yaml + - _generic-if.yaml +metadata: + device: + fields: + vendor: + value: "linksys" +sysobjectid: + - 1.3.6.1.4.1.3955.* diff --git a/snmp/tests/compose/data/linksys.snmprec b/snmp/tests/compose/data/linksys.snmprec new file mode 100644 index 0000000000000..02c55e87b46a3 --- /dev/null +++ b/snmp/tests/compose/data/linksys.snmprec @@ -0,0 +1,4 @@ +1.3.6.1.2.1.1.1.0|4|linksys Device Description +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.3955.999 +1.3.6.1.2.1.1.5.0|4|linksys.device.name +1.3.6.1.2.1.2.1.0|2|28 diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_linksys.py b/snmp/tests/test_e2e_core_profiles/test_profile_linksys.py new file mode 100644 index 0000000000000..e6e6dc281b9fc --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_linksys.py @@ -0,0 +1,56 @@ +# (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_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_linksys(dd_agent_check): + config = create_e2e_core_test_config('linksys') + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + 'snmp_profile:linksys', + 'snmp_host:linksys.device.name', + 'device_namespace:default', + 'snmp_device:' + ip_address, + ] + [] + + # --- TEST EXTENDED METRICS --- + assert_extend_generic_if(aggregator, common_tags) + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + + # --- TEST METADATA --- + device = { + 'description': 'linksys Device Description', + 'id': 'default:' + ip_address, + 'id_tags': ['device_namespace:default', 'snmp_device:' + ip_address], + 'ip_address': '' + ip_address, + 'name': 'linksys.device.name', + 'profile': 'linksys', + 'status': 1, + 'sys_object_id': '1.3.6.1.4.1.3955.999', + 'vendor': 'linksys', + } + device['tags'] = common_tags + assert_device_metadata(aggregator, device) + + # --- CHECK COVERAGE --- + aggregator.assert_all_metrics_covered() + aggregator.assert_metrics_using_metadata(get_metadata_metrics())