Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix meraki profile mac address #11871

Merged
merged 8 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ metrics:
- column:
OID: 1.3.6.1.4.1.29671.1.1.4.1.1
name: devMac
format: mac_address
tag: mac_address
- column:
OID: 1.3.6.1.4.1.29671.1.1.4.1.2
Expand Down Expand Up @@ -60,6 +61,7 @@ metrics:
- column:
OID: 1.3.6.1.4.1.29671.1.1.5.1.1
name: devInterfaceDevMac
format: mac_address
tag: mac_address
- column:
OID: 1.3.6.1.4.1.29671.1.1.5.1.2
Expand Down
53 changes: 53 additions & 0 deletions snmp/tests/test_e2e_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,56 @@ def test_e2e_regex_match(dd_agent_check):
'device_namespace:default',
],
)


def test_e2e_meraki_cloud_controller(dd_agent_check):
config = common.generate_container_instance_config([])
config['init_config']['loader'] = 'core'
instance = config['instances'][0]
instance.update(
{
'community_string': 'meraki-cloud-controller',
}
)
# run a rate check, will execute two check runs to evaluate rate metrics
aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True)

ip_address = get_container_ip(SNMP_CONTAINER_NAME)
common_tags = [
'snmp_profile:meraki-cloud-controller',
'snmp_host:dashboard.meraki.com',
'device_vendor:meraki',
'device_namespace:default',
'snmp_device:' + ip_address,
]

common.assert_common_metrics(aggregator, tags=common_tags, is_e2e=True, loader='core')

dev_metrics = ['devStatus', 'devClientCount']
dev_tags = ['product:MR16-HW', 'network:L_NETWORK', 'mac_address:02:02:00:66:f5:7f'] + common_tags
for metric in dev_metrics:
aggregator.assert_metric(
'snmp.{}'.format(metric), metric_type=aggregator.GAUGE, tags=dev_tags, count=2, device='Gymnasium'
)

if_tags = ['interface:wifi0', 'index:4', 'mac_address:02:02:00:66:f5:00'] + common_tags
if_metrics = ['devInterfaceSentPkts', 'devInterfaceRecvPkts', 'devInterfaceSentBytes', 'devInterfaceRecvBytes']
for metric in if_metrics:
aggregator.assert_metric('snmp.{}'.format(metric), metric_type=aggregator.GAUGE, tags=if_tags, count=2)

# IF-MIB
if_tags = ['interface:eth0'] + common_tags
for metric in metrics.IF_COUNTS:
aggregator.assert_metric('snmp.{}'.format(metric), metric_type=aggregator.COUNT, tags=if_tags, count=1)

for metric in metrics.IF_GAUGES:
aggregator.assert_metric('snmp.{}'.format(metric), metric_type=aggregator.GAUGE, tags=if_tags, count=2)

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

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

aggregator.assert_metric('snmp.sysUpTimeInstance', count=2, tags=common_tags)
aggregator.assert_all_metrics_covered()
19 changes: 11 additions & 8 deletions snmp/tests/test_e2e_core_vs_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'snmp.cpu.usage',
]

SKIPPED_TAGS = ['loader']
DEFAULT_TAGS_TO_SKIP = ['loader']

CORE_ONLY_TAGS = ['device_namespace:default']

Expand Down Expand Up @@ -484,7 +484,7 @@ def test_e2e_profile_isilon(dd_agent_check):

def test_e2e_profile_meraki_cloud_controller(dd_agent_check):
config = common.generate_container_profile_config('meraki-cloud-controller')
assert_python_vs_core(dd_agent_check, config)
assert_python_vs_core(dd_agent_check, config, tags_to_skip=['mac_address'])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for reviewers: We need to skip mac_address tag for python vs core tests since their format differ.



def test_e2e_profile_netapp(dd_agent_check):
Expand Down Expand Up @@ -518,6 +518,7 @@ def assert_python_vs_core(
config,
expected_total_count=None,
metrics_to_skip=None,
tags_to_skip=None,
assert_count=True,
assert_value_metrics=ASSERT_VALUE_METRICS,
rate=True,
Expand All @@ -530,6 +531,8 @@ def assert_python_vs_core(
core_config['init_config']['loader'] = 'core'
core_config['init_config']['collect_device_metadata'] = 'false'
metrics_to_skip = metrics_to_skip or []
tags_to_skip = tags_to_skip or []
tags_to_skip += DEFAULT_TAGS_TO_SKIP

# building expected metrics (python)
aggregator = dd_agent_check(python_config, rate=rate, pause=pause, times=times)
Expand All @@ -538,7 +541,7 @@ def assert_python_vs_core(
for stub in metrics:
if stub.name in metrics_to_skip:
continue
stub = normalize_stub_metric(stub)
stub = normalize_stub_metric(stub, tags_to_skip)
python_metrics[(stub.name, stub.type, tuple(sorted(list(stub.tags) + CORE_ONLY_TAGS)))].append(stub)

python_service_checks = defaultdict(list)
Expand All @@ -559,7 +562,7 @@ def assert_python_vs_core(
for stub in aggregator_metrics[metric_name]:
if stub.name in metrics_to_skip:
continue
aggregator._metrics[metric_name].append(normalize_stub_metric(stub))
aggregator._metrics[metric_name].append(normalize_stub_metric(stub, tags_to_skip))

core_metrics = defaultdict(list)
for _, metrics in aggregator._metrics.items():
Expand Down Expand Up @@ -598,8 +601,8 @@ def assert_python_vs_core(
assert expected_total_count == total_count_corecheck


def normalize_stub_metric(stub):
tags = [t for t in stub.tags if not is_skipped_tag(t)] # Remove skipped tag
def normalize_stub_metric(stub, tags_to_skip):
tags = [t for t in stub.tags if not is_skipped_tag(t, tags_to_skip)] # Remove skipped tag
return MetricStub(
stub.name,
stub.type,
Expand All @@ -610,8 +613,8 @@ def normalize_stub_metric(stub):
)


def is_skipped_tag(tag):
for skipped_tag in SKIPPED_TAGS:
def is_skipped_tag(tag, tags_to_skip):
for skipped_tag in tags_to_skip:
if tag.startswith('{}:'.format(skipped_tag)):
return True
return False