Skip to content

Commit

Permalink
Add hardware metrics for cisco (fan) (#15507)
Browse files Browse the repository at this point in the history
* Add hardware metrics for cisco (fan)

* Delete metrics from tests & restore snmprecs

* Add assertions for cisco-nexus

* Add assert_extend_cisco_generic
  • Loading branch information
lizaerem authored Aug 9, 2023
1 parent 96cb99a commit 32c8a91
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 3 deletions.
56 changes: 56 additions & 0 deletions snmp/datadog_checks/snmp/data/default_profiles/_cisco-generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ metrics:
name: ciscoEnvMonFanStatusIndex
tag: fan_status_index

- MIB: CISCO-ENVMON-MIB
table:
OID: 1.3.6.1.4.1.9.9.13.1.4
name: ciscoEnvMonFanStatusTable
symbols:
- name: ciscoEnvMonFanStatus
constant_value_one: true
metric_tags:
- column:
OID: 1.3.6.1.4.1.9.9.13.1.4.1.3
name: ciscoEnvMonFanState
tag: fan_state
mapping:
1: normal
2: warning
3: critical
4: shutdown
5: notPresent
6: notFunctioning
- column:
OID: 1.3.6.1.4.1.9.9.13.1.4.1.2
name: ciscoEnvMonFanStatusDescr
tag: fan_status_descr
- column:
OID: 1.3.6.1.4.1.9.9.13.1.4.1.1
name: ciscoEnvMonFanStatusIndex
tag: fan_status_index

# stackport specific info - every physical stackport has an entry in ifTable
- MIB: CISCO-STACKWISE-MIB
table:
Expand Down Expand Up @@ -175,6 +203,34 @@ metrics:
- index: 1
tag: fru

- MIB: CISCO-ENTITY-FRU-CONTROL-MIB
table:
OID: 1.3.6.1.4.1.9.9.117.1.4.1
name: cefcFanTrayStatusTable
symbols:
- name: cefcFanTrayStatus
constant_value_one: true
metric_tags:
- index: 1
tag: fru
- column:
OID: 1.3.6.1.4.1.9.9.117.1.4.1.1.1
name: cefcFanTrayOperStatus
tag: cefc_fan_tray_oper_status
mapping:
1: unknown
2: up
3: down
4: warning
- column:
OID: 1.3.6.1.4.1.9.9.117.1.4.1.1.2
name: cefcFanTrayDirection
tag: cefc_fan_tray_direction
mapping:
1: unknown
2: frontToBack
3: backToFront

- MIB: CISCO-MEMORY-POOL-MIB
table:
OID: 1.3.6.1.4.1.9.9.48.1.1
Expand Down
2 changes: 2 additions & 0 deletions snmp/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ snmp.cefcFRUCurrent,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] Curren
snmp.cefcFRUPowerAdminStatus,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] Administratively desired FRU power state.,0,snmp,,
snmp.cefcFRUPowerOperStatus,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] Operational FRU power state.,0,snmp,,
snmp.cefcFanTrayOperStatus,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] The operational state of the fan or fan tray.,0,snmp,,
snmp.cefcFanTrayStatus,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] cefcFanTrayStatusTable. Constant metric equal to 1,0,snmp,,
snmp.cfInterconnectStatus,gauge,,,,"[NetApp] The current status of the interconnect (notPresent(1), down(2), partialFailure(3), up(4)).",0,snmp,,
snmp.cfprEquipmentFan,gauge,,,,"[CISCO-FIREPOWER-EQUIPMENT-MIB] Cisco Firepower equipment:Fan managed object table (Make 'sum by {X}' queries to count elements with the tag X.)",0,snmp,,
snmp.cfprEquipmentPsu,gauge,,,,"[CISCO-FIREPOWER-EQUIPMENT-MIB] Cisco Firepower equipment:Psu managed object table (Make 'sum by {X}' queries to count elements with the tag X.)",0,snmp,,
Expand All @@ -218,6 +219,7 @@ snmp.cipSecGlobalActiveTunnels,gauge,,,,[Cisco ASA 5525] The total number of cur
snmp.cipSecGlobalHcInOctets,count,,,,[Cisco ASA 5525] A high capacity count of the total number of octets received by all current and previous IPsec Phase-2 Tunnels.,0,snmp,,
snmp.cipSecGlobalHcOutOctets,count,,,,[Cisco ASA 5525] A high capacity count of the total number of octets sent by all current and previous IPsec Phase-2 Tunnels.,0,snmp,,
snmp.ciscoEnvMonFanState,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] The current state of the fan being instrumented.,0,snmp,,
snmp.ciscoEnvMonFanStatus,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] ciscoEnvMonFanStatusTable. Constant metric equal to 1,0,snmp,,
snmp.ciscoEnvMonSupplyState,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] The current state of the power supply being instrumented.,0,snmp,,
snmp.ciscoEnvMonSupplyStatus,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] Supply status table. Constant metric equal to 1.,0,snmp,,
snmp.ciscoEnvMonTemperatureStatusValue,gauge,,,,[Cisco c3850] [Cisco Nexus] [Cisco ASA 5525] The current value of the testpoint being instrumented.,0,snmp,,
Expand Down
2 changes: 2 additions & 0 deletions snmp/tests/compose/data/cisco-access-point.snmprec
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
1.3.6.1.2.1.31.1.1.1.1.21|4|eth12
1.3.6.1.2.1.31.1.1.1.1.23|4|eth0
1.3.6.1.2.1.31.1.1.1.1.30|4|eth1
1.3.6.1.4.1.9.9.13.1.4.1.1.11|2|11
1.3.6.1.4.1.9.9.13.1.4.1.3.11|2|6
1.3.6.1.4.1.9.9.109.1.1.1.1.12.712|66|353
1.3.6.1.4.1.9.9.273.1.1.1.0|4x|000000000000
1.3.6.1.4.1.9.9.273.1.1.2.1.1.23|66|2000
Expand Down
2 changes: 2 additions & 0 deletions snmp/tests/compose/data/cisco-load-balancer.snmprec
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
1.3.6.1.2.1.1.1.0|4|cisco-load-balancer Device Description
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.9.1.824
1.3.6.1.2.1.1.5.0|4|cisco-load-balancer.device.name
1.3.6.1.4.1.9.9.13.1.4.1.1.11|2|11
1.3.6.1.4.1.9.9.13.1.4.1.3.11|2|6
1.3.6.1.4.1.9.9.109.1.1.1.1.12.712|66|353
1.3.6.1.4.1.9.9.161.1.1.1.1.1.11128|66|11128
1.3.6.1.4.1.9.9.161.1.1.1.1.1.52836|66|52836
Expand Down
2 changes: 2 additions & 0 deletions snmp/tests/compose/data/cisco-wan-optimizer.snmprec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
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
1.3.6.1.4.1.9.9.13.1.4.1.1.11|2|11
1.3.6.1.4.1.9.9.13.1.4.1.3.11|2|6
1.3.6.1.4.1.9.9.178.1.1.1.1.0|65|3129595330
1.3.6.1.4.1.9.9.178.1.1.1.2.0|65|1937924569
1.3.6.1.4.1.9.9.178.1.1.1.3.0|65|2909442301
Expand Down
2 changes: 2 additions & 0 deletions snmp/tests/compose/data/cisco.snmprec
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
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.13.1.4.1.1.11|2|11
1.3.6.1.4.1.9.9.13.1.4.1.3.11|2|6
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
21 changes: 21 additions & 0 deletions snmp/tests/test_e2e_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,27 @@ def test_e2e_cisco_nexus(dd_agent_check):
'snmp.cefcFanTrayOperStatus', metric_type=aggregator.GAUGE, tags=['fru:{}'.format(fru)] + common_tags
)

tag_rows = [
['fru:1', 'cefc_fan_tray_oper_status:down'],
['fru:2', 'cefc_fan_tray_oper_status:unknown'],
['fru:4', 'cefc_fan_tray_oper_status:unknown'],
['fru:27', 'cefc_fan_tray_oper_status:unknown'],
['fru:30', 'cefc_fan_tray_oper_status:warning'],
['fru:31', 'cefc_fan_tray_oper_status:unknown'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.cefcFanTrayStatus', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['fan_status_descr:fan_1', 'fan_state:critical', 'fan_status_index:4'],
['fan_status_descr:fan_2', 'fan_state:notFunctioning', 'fan_status_index:6'],
['fan_status_descr:fan_3', 'fan_state:critical', 'fan_status_index:7'],
['fan_status_descr:fan_4', 'fan_state:notPresent', 'fan_status_index:16'],
['fan_status_descr:fan_8', 'fan_state:normal', 'fan_status_index:30'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.ciscoEnvMonFanStatus', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

cpu_ids = [6692, 3173, 54474, 63960, 11571, 38253, 30674, 52063]
for cpu in cpu_ids:
aggregator.assert_metric(
Expand Down
20 changes: 20 additions & 0 deletions snmp/tests/test_e2e_core_profiles/test_profile__cisco_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ def test_e2e_profile__cisco_generic(dd_agent_check):
for tag_row in tag_rows:
aggregator.assert_metric('snmp.ciscoEnvMonFanState', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['fan_status_index:11', 'fan_state:notFunctioning', 'fan_status_descr:oxen their but kept forward kept'],
['fan_status_index:16', 'fan_state:normal', 'fan_status_descr:acted'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.ciscoEnvMonFanStatus', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

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

tag_rows = [
Expand All @@ -142,6 +149,19 @@ def test_e2e_profile__cisco_generic(dd_agent_check):
for tag_row in tag_rows:
aggregator.assert_metric('snmp.cefcFanTrayOperStatus', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['fru:21', 'cefc_fan_tray_oper_status:warning', 'cefc_fan_tray_direction:frontToBack'],
['fru:23', 'cefc_fan_tray_oper_status:up', 'cefc_fan_tray_direction:frontToBack'],
['fru:25', 'cefc_fan_tray_oper_status:unknown', 'cefc_fan_tray_direction:frontToBack'],
['fru:27', 'cefc_fan_tray_oper_status:unknown', 'cefc_fan_tray_direction:unknown'],
['fru:29', 'cefc_fan_tray_oper_status:unknown', 'cefc_fan_tray_direction:backToFront'],
['fru:30', 'cefc_fan_tray_oper_status:up', 'cefc_fan_tray_direction:backToFront'],
['fru:7', 'cefc_fan_tray_oper_status:up', 'cefc_fan_tray_direction:backToFront'],
['fru:9', 'cefc_fan_tray_oper_status:warning', 'cefc_fan_tray_direction:unknown'],
]
for tag_row in tag_rows:
aggregator.assert_metric('snmp.cefcFanTrayStatus', metric_type=aggregator.GAUGE, tags=common_tags + tag_row)

tag_rows = [
['mem_pool_name:but their kept quaintly driving'],
['mem_pool_name:zombies kept their oxen'],
Expand Down
2 changes: 2 additions & 0 deletions snmp/tests/test_e2e_core_profiles/test_profile_cisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .utils import (
assert_common_metrics,
assert_extend_cisco_cpu_memory,
assert_extend_cisco_generic,
assert_extend_generic_bgp4,
assert_extend_generic_if,
assert_extend_generic_ip,
Expand Down Expand Up @@ -45,6 +46,7 @@ def test_e2e_profile_cisco(dd_agent_check):
assert_extend_generic_ospf(aggregator, common_tags)
assert_extend_generic_bgp4(aggregator, common_tags)
assert_extend_cisco_cpu_memory(aggregator, common_tags)
assert_extend_cisco_generic(aggregator, common_tags)
aggregator.assert_all_metrics_covered()
aggregator.assert_metrics_using_metadata(get_metadata_metrics())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .utils import (
assert_common_metrics,
assert_extend_cisco,
assert_extend_cisco_generic,
create_e2e_core_test_config,
get_device_ip_from_config,
)
Expand All @@ -32,6 +33,7 @@ def test_e2e_profile_cisco_access_point(dd_agent_check):

# --- TEST EXTENDED METRICS ---
assert_extend_cisco(aggregator, common_tags)
assert_extend_cisco_generic(aggregator, common_tags)

# --- TEST METRICS ---
assert_common_metrics(aggregator, common_tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .utils import (
assert_common_metrics,
assert_extend_cisco,
assert_extend_cisco_generic,
create_e2e_core_test_config,
get_device_ip_from_config,
)
Expand All @@ -33,6 +34,7 @@ def test_e2e_profile_cisco_load_balancer(dd_agent_check):
# --- TEST EXTENDED METRICS ---
# Examples:
assert_extend_cisco(aggregator, common_tags)
assert_extend_cisco_generic(aggregator, common_tags)

# --- TEST METRICS ---
assert_common_metrics(aggregator, common_tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ..test_e2e_core_metadata import assert_device_metadata
from .utils import (
assert_common_metrics,
assert_extend_cisco_generic,
assert_extend_generic_host_resources_base,
create_e2e_core_test_config,
get_device_ip_from_config,
Expand All @@ -32,6 +33,7 @@ def test_e2e_profile_cisco_wan_optimizer(dd_agent_check):

# --- TEST EXTENDED METRICS ---
assert_extend_generic_host_resources_base(aggregator, common_tags)
assert_extend_cisco_generic(aggregator, common_tags)

# --- TEST METRICS ---
assert_common_metrics(aggregator, common_tags)
Expand Down
17 changes: 17 additions & 0 deletions snmp/tests/test_e2e_core_profiles/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ def assert_extend_cisco_cpu_memory(aggregator, common_tags):
)


def assert_extend_cisco_generic(aggregator, common_tags):
# fmt: off
"""Add the following to the snmprec
1.3.6.1.4.1.9.9.13.1.4.1.1.11|2|11
1.3.6.1.4.1.9.9.13.1.4.1.3.11|2|6
"""
# fmt: on
aggregator.assert_metric(
'snmp.ciscoEnvMonFanStatus',
metric_type=aggregator.GAUGE,
tags=common_tags + ['fan_state:notFunctioning', 'fan_status_index:11'],
)
aggregator.assert_metric(
'snmp.ciscoEnvMonFanState', metric_type=aggregator.GAUGE, tags=common_tags + ['fan_status_index:11']
)


def assert_extend_generic_host_resources_base(aggregator, common_tags):
# fmt: off
"""Add the following to the snmprec
Expand Down
31 changes: 28 additions & 3 deletions snmp/tests/test_e2e_core_vs_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
'snmp.upsOutletGroupStatus', # APC UPS constant metric
'snmp.cpiPduEas', # Chatsworth constant metric
'snmp.ciscoEnvMonSupplyStatus', # Cisco constant metric
'snmp.ciscoEnvMonFanStatus', # Cisco constant metric
'snmp.cefcFanTrayStatus', # Cisco constant metric
'snmp.cpqHeFltTolPowerSupply', # HP constant metric
]

Expand Down Expand Up @@ -356,7 +358,14 @@ def test_e2e_profile_cisco_3850(dd_agent_check):
config,
expected_total_count=5108 + 5,
metrics_to_skip=metrics_to_skip,
tags_to_skip=['neighbor_state', 'if_state', 'cisco_env_mon_supply_state'], # Ignore tags that have a mapping
tags_to_skip=[
'neighbor_state',
'if_state',
'cisco_env_mon_supply_state',
'fan_state',
'cefc_fan_tray_oper_status',
'cefc_fan_tray_direction',
], # Ignore tags that have mappings
)


Expand All @@ -367,7 +376,12 @@ def test_e2e_profile_cisco_asa(dd_agent_check):
dd_agent_check,
config,
metrics_to_skip=metrics_to_skip,
tags_to_skip=['cisco_env_mon_supply_state'], # Ignore tag that has a mapping
tags_to_skip=[
'cisco_env_mon_supply_state',
'fan_state',
'cefc_fan_tray_oper_status',
'cefc_fan_tray_direction',
], # Ignore tags that have mappings
)


Expand All @@ -378,6 +392,12 @@ def test_e2e_profile_cisco_asa_5525(dd_agent_check):
dd_agent_check,
config,
metrics_to_skip=metrics_to_skip,
tags_to_skip=[
'cisco_env_mon_supply_state',
'fan_state',
'cefc_fan_tray_oper_status',
'cefc_fan_tray_direction',
], # Ignore tags that have mappings
)


Expand All @@ -400,7 +420,12 @@ def test_e2e_profile_cisco_nexus(dd_agent_check):
dd_agent_check,
config,
metrics_to_skip=metrics_to_skip,
tags_to_skip=['cisco_env_mon_supply_state'], # Ignore tag that has a mapping
tags_to_skip=[
'cisco_env_mon_supply_state',
'fan_state',
'cefc_fan_tray_oper_status',
'cefc_fan_tray_direction',
], # Ignore tags that have mappings
)


Expand Down

0 comments on commit 32c8a91

Please sign in to comment.