diff --git a/snmp/datadog_checks/snmp/data/profiles/3com-huawei.yaml b/snmp/datadog_checks/snmp/data/profiles/3com-huawei.yaml new file mode 100644 index 0000000000000..1e71bab9a797b --- /dev/null +++ b/snmp/datadog_checks/snmp/data/profiles/3com-huawei.yaml @@ -0,0 +1,67 @@ +extends: + - 3com.yaml + +sysobjectid: + - 1.3.6.1.4.1.43.45.1.2.* # 3Com Huawei Products (a3Com.jv-mib.huawei.hwproducts) + +metrics: + - MIB: A3COM-HUAWEI-LswDEVM-MIB + table: + name: hwCpuTable # indexes: hwCpuIndex + OID: 1.3.6.1.4.1.43.45.1.6.1.1 + symbols: + - name: cpu.usage + OID: 1.3.6.1.4.1.43.45.1.6.1.1.1.3 + metric_tags: + - index: 1 + tag: cpu + - MIB: A3COM-HUAWEI-LswDEVM-MIB + table: + name: hwMemTable # indexes: hwMemModuleIndex + OID: 1.3.6.1.4.1.43.45.1.6.1.2.1 + symbols: + - name: memory.total + OID: 1.3.6.1.4.1.43.45.1.6.1.2.1.1.2 + - name: memory.free + OID: 1.3.6.1.4.1.43.45.1.6.1.2.1.1.3 + metric_tags: + - index: 1 + tag: mem + - MIB: A3COM-HUAWEI-LswDEVM-MIB + table: + name: hwdevMFanStatusTable # indexes: hwDevMFanNum + OID: 1.3.6.1.4.1.43.45.1.2.23.1.9.1.1 + symbols: + - name: hwdevMFan + constant_value_one: true + metric_tags: + - index: 1 + tag: fan_num + - column: + OID: 1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2 + name: hwDevMFanStatus + tag: fan_status + mapping: + 1: active + 2: deactive + 3: not_installed + 4: unsupported + - MIB: A3COM-HUAWEI-LswDEVM-MIB + table: + name: hwdevMPowerStatusTable # indexes: hwDevMPowerNum + OID: 1.3.6.1.4.1.43.45.1.2.23.1.9.1.2 + symbols: + - name: hwdevMPowerStatus + constant_value_one: true + metric_tags: + - index: 1 + tag: power_num + - column: + OID: 1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1.2 + name: hwDevMPowerStatus + tag: power_status + mapping: + 1: active + 2: deactive + 3: not_installed + 4: unsupported diff --git a/snmp/datadog_checks/snmp/data/profiles/3com.yaml b/snmp/datadog_checks/snmp/data/profiles/3com.yaml new file mode 100644 index 0000000000000..4b72160a2263a --- /dev/null +++ b/snmp/datadog_checks/snmp/data/profiles/3com.yaml @@ -0,0 +1,12 @@ +extends: + - _base.yaml + - _generic-if.yaml + +metadata: + device: + fields: + vendor: + value: "3com" + +sysobjectid: + - 1.3.6.1.4.1.43.1.* # 3Com products diff --git a/snmp/tests/compose/data/3com-huawei.snmprec b/snmp/tests/compose/data/3com-huawei.snmprec new file mode 100644 index 0000000000000..0a4a0d0f790fe --- /dev/null +++ b/snmp/tests/compose/data/3com-huawei.snmprec @@ -0,0 +1,18 @@ +1.3.6.1.2.1.1.1.0|4|3Com Huawei Device Desc +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.43.45.1.2.999 +1.3.6.1.2.1.1.5.0|4|3com-huawei.device.name +1.3.6.1.2.1.2.1.0|2|4 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.11|2|1 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.12|2|2 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.13|2|3 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.14|2|4 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1.2.11|2|1 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1.2.12|2|2 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1.2.13|2|3 +1.3.6.1.4.1.43.45.1.2.23.1.9.1.2.1.2.14|2|4 +1.3.6.1.4.1.43.45.1.6.1.1.1.3.881|2|42 +1.3.6.1.4.1.43.45.1.6.1.1.1.3.882|2|52 +1.3.6.1.4.1.43.45.1.6.1.2.1.1.2.991|2|100 +1.3.6.1.4.1.43.45.1.6.1.2.1.1.2.992|2|100 +1.3.6.1.4.1.43.45.1.6.1.2.1.1.3.991|2|100 +1.3.6.1.4.1.43.45.1.6.1.2.1.1.3.992|2|100 diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_3com_huawei.py b/snmp/tests/test_e2e_core_profiles/test_profile_3com_huawei.py new file mode 100644 index 0000000000000..44f549cfc4594 --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_3com_huawei.py @@ -0,0 +1,85 @@ +# (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_3com_huawei(dd_agent_check): + config = create_e2e_core_test_config('3com-huawei') + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + 'snmp_profile:3com-huawei', + 'snmp_host:3com-huawei.device.name', + 'device_namespace:default', + 'snmp_device:' + ip_address, + ] + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + assert_extend_generic_if(aggregator, common_tags) + + cpu_ids = [881, 882] + for cpu in cpu_ids: + cpu_tags = common_tags + ['cpu:{}'.format(cpu)] + aggregator.assert_metric('snmp.cpu.usage', metric_type=aggregator.GAUGE, tags=cpu_tags) + + mem_ids = [991, 992] + for mem in mem_ids: + mem_tags = common_tags + ['mem:{}'.format(mem)] + aggregator.assert_metric('snmp.memory.free', metric_type=aggregator.GAUGE, tags=mem_tags) + aggregator.assert_metric('snmp.memory.total', metric_type=aggregator.GAUGE, tags=mem_tags) + aggregator.assert_metric('snmp.memory.usage', metric_type=aggregator.GAUGE, tags=mem_tags) + + fan_row_tags = [ + ["fan_num:11", "fan_status:active"], + ["fan_num:12", "fan_status:deactive"], + ["fan_num:13", "fan_status:not_installed"], + ["fan_num:14", "fan_status:unsupported"], + ] + for fan_tags in fan_row_tags: + aggregator.assert_metric('snmp.hwdevMFan', metric_type=aggregator.GAUGE, tags=common_tags + fan_tags) + + fan_row_tags = [ + ["power_num:11", "power_status:active"], + ["power_num:12", "power_status:deactive"], + ["power_num:13", "power_status:not_installed"], + ["power_num:14", "power_status:unsupported"], + ] + for fan_tags in fan_row_tags: + aggregator.assert_metric('snmp.hwdevMPowerStatus', metric_type=aggregator.GAUGE, tags=common_tags + fan_tags) + + aggregator.assert_all_metrics_covered() + + # --- TEST METADATA --- + device = { + 'description': '3Com Huawei Device Desc', + 'id': 'default:' + ip_address, + 'id_tags': ['device_namespace:default', 'snmp_device:' + ip_address], + 'ip_address': '' + ip_address, + 'name': '3com-huawei.device.name', + 'profile': '3com-huawei', + 'status': 1, + 'sys_object_id': '1.3.6.1.4.1.43.45.1.2.999', + 'tags': [ + 'device_namespace:default', + 'snmp_device:' + ip_address, + 'snmp_host:3com-huawei.device.name', + 'snmp_profile:3com-huawei', + ], + 'vendor': '3com', + } + assert_device_metadata(aggregator, device)