Skip to content

Commit

Permalink
Add hardware metrics for Fortinet (non-categorical) (#15553)
Browse files Browse the repository at this point in the history
* Add hardware metrics Fortinet (non-categorical)

* Update test_e2e_core_metadata.py

* Fix comments & tests

* Update changelog
  • Loading branch information
lizaerem authored Aug 17, 2023
1 parent eb7b58f commit 44fb344
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 7 deletions.
1 change: 1 addition & 0 deletions snmp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Add hardware metrics for Dell (non-categorical) ([#15567](https://github.com/DataDog/integrations-core/pull/15567))
* Add hardware metrics for F5 (non-categorical) ([#15568](https://github.com/DataDog/integrations-core/pull/15568))
* Add hardware metrics for Fortinet (non-categorical) ([#15553](https://github.com/DataDog/integrations-core/pull/15553))

## 6.1.0 / 2023-08-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,31 @@ metrics:
OID: 1.3.6.1.4.1.12356.101.3.2.1.1.2
name: fgVdEntName

- MIB: FORTINET-FORTIGATE-MIB
table:
OID: 1.3.6.1.4.1.12356.101.3.2.1
name: fgVdTable
symbols:
- name: fgVirtualDomain
constant_value_one: true
metric_tags:
- tag: virtualdomain_index
column:
OID: 1.3.6.1.4.1.12356.101.3.2.1.1.1
name: fgVdEntIndex
- tag: virtualdomain_name
column:
OID: 1.3.6.1.4.1.12356.101.3.2.1.1.2
name: fgVdEntName
- tag: virtualdomain_state
column:
OID: 1.3.6.1.4.1.12356.101.3.2.1.1.4
name: fgVdEntHaState
mapping:
1: primary
2: secondary
3: standalone

- MIB: FORTINET-FORTIGATE-MIB
symbol:
# The number of virtual domains in vdTable.
Expand Down
1 change: 1 addition & 0 deletions snmp/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ snmp.fgSysSes6Count,gauge,,session,,[Fortinet FortiGate] The number of active ip
snmp.fgSysSes6Rate1,gauge,,session,second,[Fortinet FortiGate] The average ipv6 session setup rate over the past minute.,0,snmp,,
snmp.fgSysSesCount,gauge,,session,,[Fortinet FortiGate] The number of active sessions on the device.,0,snmp,,
snmp.fgSysSesRate1,gauge,,session,second,[Fortinet FortiGate] The average session setup rate over the past minute.,0,snmp,,
snmp.fgVirtualDomain,gauge,,,,"[Fortinet FortiGate] A table of virtual domains configured on the device. Constant metric equal to 1",0,snmp,,
snmp.fgVdEntCpuUsage,gauge,,percent,,[Fortinet FortiGate] The CPU usage of the virtual domain (percentage).,0,snmp,,
snmp.fgVdEntHaState,gauge,,,,[Fortinet FortiGate] The HA cluster member state of the virtual domain on this device: master(1) backup(2) standalone(3),0,snmp,,
snmp.fgVdEntMemUsage,gauge,,percent,,[Fortinet FortiGate] The memory usage of the virtual domain (percentage).,0,snmp,,
Expand Down
7 changes: 5 additions & 2 deletions snmp/tests/compose/data/fortinet-fortigate.snmprec
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
1.3.6.1.2.1.1.2.0|4|1.3.6.1.4.1.12356.101.1.1
1.3.6.1.2.1.1.5.0|4|fortinet-fortigate.device.name
1.3.6.1.2.1.2.1.0|2|28
1.3.6.1.2.1.31.1.1.1.1.4|4|le0
1.3.6.1.2.1.47.1.1.1.1.2.1|4|Fortinet FGT_501E, HW Serial#: FG5H1E5110000000
1.3.6.1.2.1.47.1.1.1.1.3.1|6|1.3.6.1.4.1.12356.5006.5006.0
1.3.6.1.2.1.47.1.1.1.1.4.1|2|0
Expand Down Expand Up @@ -64,12 +67,12 @@
1.3.6.1.4.1.12356.101.5.1.2.2.1.2.5.29|70|13218909809640136190
1.3.6.1.4.1.12356.101.5.1.2.2.1.3.5.29|70|9058397767704808189
1.3.6.1.4.1.12356.101.5.1.2.2.1.4.5.29|4x|4a61646564204a61646564
1.3.6.1.4.1.12356.101.7.2.1.1.1.1|2|19
1.3.6.1.4.1.12356.101.7.2.1.1.1.4|2|19
1.3.6.1.4.1.12356.101.10.100.4.0|66|25504
1.3.6.1.4.1.12356.101.10.100.5.0|66|817
1.3.6.1.4.1.12356.101.12.2.2.1.2.1|4|ESMAO-Lomtec
1.3.6.1.4.1.12356.101.12.2.2.1.2.2|4|ESMAO
1.3.6.1.4.1.12356.101.12.2.2.1.18.1|70|3896031866066683889
1.3.6.1.4.1.12356.101.12.2.2.1.18.1|70|389603186606668388
1.3.6.1.4.1.12356.101.12.2.2.1.18.2|70|13218909809640136190
1.3.6.1.4.1.12356.101.12.2.2.1.19.1|70|3518073560493506800
1.3.6.1.4.1.12356.101.12.2.2.1.19.2|70|9058397767704808189
Expand Down
2 changes: 2 additions & 0 deletions snmp/tests/test_e2e_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ def test_e2e_core_metadata_fortinet_fortigate(dd_agent_check):
],
'ip_address': device_ip,
'model': 'FGT_501E',
'name': 'fortinet-fortigate.device.name',
'os_name': 'FortiOS',
'os_version': '5.6.4',
'product_name': 'FortiGate-501E',
Expand All @@ -868,6 +869,7 @@ def test_e2e_core_metadata_fortinet_fortigate(dd_agent_check):
'device_namespace:default',
'device_vendor:fortinet',
'snmp_device:' + device_ip,
'snmp_host:fortinet-fortigate.device.name',
'snmp_profile:fortinet-fortigate',
],
'vendor': 'fortinet',
Expand Down
163 changes: 163 additions & 0 deletions snmp/tests/test_e2e_core_profiles/test_profile_fortinet_fortigate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# (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_fortinet_fortigate_cpu_memory,
assert_extend_fortinet_fortigate_vpn_tunnel,
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_fortigate(dd_agent_check):
config = create_e2e_core_test_config('fortinet-fortigate')
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-fortigate',
'snmp_host:fortinet-fortigate.device.name',
'device_namespace:default',
'snmp_device:' + ip_address,
'device_vendor:fortinet',
] + []

# --- TEST EXTENDED METRICS ---
assert_extend_generic_if(aggregator, common_tags)
assert_extend_fortinet_fortigate_cpu_memory(aggregator, common_tags)
assert_extend_fortinet_fortigate_vpn_tunnel(aggregator, common_tags)

# --- TEST METRICS ---
assert_common_metrics(aggregator, common_tags)

aggregator.assert_metric('snmp.cpu.usage', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.memory.usage', metric_type=aggregator.GAUGE, tags=common_tags)

aggregator.assert_metric('snmp.fgApHTTPConnections', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgApHTTPMaxConnections', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysCpuUsage', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysDiskCapacity', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysDiskUsage', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysLowMemCapacity', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysLowMemUsage', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysMemCapacity', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysMemUsage', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysSes6Count', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysSes6Rate1', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysSesCount', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgSysSesRate1', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgVdMaxVdoms', metric_type=aggregator.GAUGE, tags=common_tags)
aggregator.assert_metric('snmp.fgVdNumber', metric_type=aggregator.GAUGE, tags=common_tags)
tag_rows = [
['processor_index:12'],
]
for tag_row in tag_rows:
aggregator.assert_metric(
'snmp.fgProcessorPktDroppedCount', metric_type=aggregator.COUNT, tags=common_tags + tag_row
)
aggregator.assert_metric(
'snmp.fgProcessorPktDroppedCount.rate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row
)
aggregator.assert_metric('snmp.fgProcessorPktRxCount', metric_type=aggregator.COUNT, tags=common_tags + tag_row)
aggregator.assert_metric(
'snmp.fgProcessorPktRxCount.rate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row
)
aggregator.assert_metric('snmp.fgProcessorPktTxCount', metric_type=aggregator.COUNT, tags=common_tags + tag_row)
aggregator.assert_metric(
'snmp.fgProcessorPktTxCount.rate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row
)

tag_rows = [
['processor_index:12'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.fgProcessorSysUsage', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgProcessorUsage', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['virtualdomain_index:4', 'virtualdomain_name:their oxen quaintly'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.fgVdEntCpuUsage', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgVdEntHaState', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgVdEntMemUsage', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgVdEntOpMode', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgVdEntSesCount', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgVdEntSesRate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

phase1_name = [
'ESMAO-Lomtec',
'ESMAO',
]
for name in phase1_name:
tags = common_tags + ['vpn_tunnel:' + name]
aggregator.assert_metric('snmp.fgVpnTunEntInOctets', metric_type=aggregator.GAUGE, tags=tags)
aggregator.assert_metric('snmp.fgVpnTunEntOutOctets', metric_type=aggregator.GAUGE, tags=tags)
aggregator.assert_metric('snmp.fgVpnTunEntStatus', metric_type=aggregator.GAUGE, tags=tags)

tag_rows = [
['virtualdomain_index:4', 'virtualdomain_name:their oxen quaintly', 'virtualdomain_state:secondary'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.fgVirtualDomain', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['virtualdomain_index:4', 'interface:le0'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.fgIntfEntVdom', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['policy_index:22', 'virtualdomain_index:2'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.fgFwPolByteCount', metric_type=aggregator.COUNT, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgFwPolByteCount.rate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgFwPolPktCount', metric_type=aggregator.COUNT, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgFwPolPktCount.rate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['policy6_index:29', 'virtualdomain_index:5'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.fgFwPol6ByteCount', metric_type=aggregator.COUNT, tags=common_tags + tag_row)
aggregator.assert_metric(
'snmp.fgFwPol6ByteCount.rate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row
)
aggregator.assert_metric('snmp.fgFwPol6PktCount', metric_type=aggregator.COUNT, tags=common_tags + tag_row)
aggregator.assert_metric('snmp.fgFwPol6PktCount.rate', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

# --- TEST METADATA ---
device = {
'id': 'default:' + ip_address,
'id_tags': ['device_namespace:default', 'snmp_device:' + ip_address],
'ip_address': '' + ip_address,
'model': 'FGT_501E',
'name': 'fortinet-fortigate.device.name',
'os_name': 'FortiOS',
'os_version': '5.6.4',
'product_name': 'FortiGate-501E',
'profile': 'fortinet-fortigate',
'serial_number': 'FG5H1E5110000000',
'status': 1,
'sys_object_id': '1.3.6.1.4.1.12356.101.1.1',
'vendor': 'fortinet',
'version': 'v5.6.4,build1575b1575,180425 (GA)',
}
device['tags'] = common_tags
assert_device_metadata(aggregator, device)

# --- CHECK COVERAGE ---
aggregator.assert_all_metrics_covered()
aggregator.assert_metrics_using_metadata(get_metadata_metrics())
21 changes: 21 additions & 0 deletions snmp/tests/test_e2e_core_profiles/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ def assert_extend_aruba_switch_cpu_memory(aggregator, common_tags):
aggregator.assert_metric("snmp.cpu.usage", metric_type=aggregator.GAUGE, tags=common_tags + ['cpu:4'])


def assert_extend_fortinet_fortigate_cpu_memory(aggregator, common_tags):
# fmt: off
"""Add the following to the snmprec
1.3.6.1.4.1.12356.101.4.1.3.0|66|10
"""
# fmt: on
aggregator.assert_metric("snmp.cpu.usage", metric_type=aggregator.GAUGE, tags=common_tags)


def assert_extend_fortinet_fortigate_vpn_tunnel(aggregator, common_tags):
# fmt: off
"""Add the following to the snmprec
1.3.6.1.4.1.12356.101.12.2.2.1.2.2|4|ESMAO
1.3.6.1.4.1.12356.101.12.2.2.1.20.2|2|1
"""
# fmt: on
aggregator.assert_metric(
'snmp.fgVpnTunEntStatus', metric_type=aggregator.GAUGE, tags=common_tags + ['vpn_tunnel:ESMAO']
)


def assert_extend_generic_if(aggregator, common_tags):
# fmt: off
"""Add the following to the snmprec
Expand Down
7 changes: 2 additions & 5 deletions snmp/tests/test_e2e_core_vs_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'snmp.cpqHeFltTolPowerSupply', # HP constant metric
'snmp.fanSpeedSensor', # Checkpoint constant metric
'snmp.enclosurePowerSupply', # iDRAC constant metric
'snmp.fgVirtualDomain', # Fortinet-Fortigate constant metric
'snmp.systemState', # Dell-Poweredge constant metric
'snmp.dell.systemState', # iDRAC constant metric
'snmp.dell.physicalDisk', # iDRAC constant metric
Expand Down Expand Up @@ -513,11 +514,7 @@ def test_e2e_core_vs_python_profile_f5_big_ip(dd_agent_check):
def test_e2e_profile_fortinet_fortigate(dd_agent_check):
config = common.generate_container_profile_config("fortinet-fortigate")
metrics_to_skip = SKIPPED_CORE_ONLY_METRICS
assert_python_vs_core(
dd_agent_check,
config,
metrics_to_skip=metrics_to_skip,
)
assert_python_vs_core(dd_agent_check, config, metrics_to_skip=metrics_to_skip, tags_to_skip=['fgVdEntHaState'])


def test_e2e_profile_generic_device(dd_agent_check):
Expand Down
3 changes: 3 additions & 0 deletions snmp/tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,7 @@ def test_fortinet_fortigate(aggregator):
common_tags = common.CHECK_TAGS + [
'snmp_profile:fortinet-fortigate',
'device_vendor:fortinet',
'snmp_host:fortinet-fortigate.device.name',
]

common_gauge_metrics = [
Expand Down Expand Up @@ -2697,6 +2698,8 @@ def test_fortinet_fortigate(aggregator):

common.assert_common_metrics(aggregator, common_tags)

aggregator.assert_metric('snmp.ifNumber', metric_type=aggregator.GAUGE, tags=common_tags)

for metric in common_gauge_metrics:
aggregator.assert_metric('snmp.{}'.format(metric), metric_type=aggregator.GAUGE, tags=common_tags, count=1)

Expand Down

0 comments on commit 44fb344

Please sign in to comment.