Skip to content
Permalink
Browse files

10212 FIX aws_limits: Fixed parsing old agent data which does not con…

…tain information about region

Change-Id: I8605110190c9058331152ac3dee9c3e96c40e4b0
  • Loading branch information...
si-23 committed Oct 8, 2019
1 parent 65ec66f commit 12c0195f86445c1307b2d4e851868781c5666482
Showing with 884 additions and 38 deletions.
  1. +11 −0 .werks/10212
  2. +13 −0 checks/aws.include
  3. +1 −6 checks/aws_cloudwatch_alarms_limits
  4. +3 −1 checks/aws_ebs_limits
  5. +1 −6 checks/aws_ec2_limits
  6. +1 −6 checks/aws_elb_limits
  7. +1 −6 checks/aws_elbv2_limits
  8. +1 −6 checks/aws_glacier_limits
  9. +3 −1 checks/aws_rds_limits
  10. +1 −6 checks/aws_s3_limits
  11. +27 −0 tests/unit/checks/generictests/datasets/aws_cloudwatch_alarms_limits_1.py
  12. +27 −0 tests/unit/checks/generictests/datasets/aws_cloudwatch_alarms_limits_2.py
  13. +33 −0 tests/unit/checks/generictests/datasets/aws_ebs_limits_1.py
  14. +33 −0 tests/unit/checks/generictests/datasets/aws_ebs_limits_2.py
  15. +212 −0 tests/unit/checks/generictests/datasets/aws_ec2_limits_1.py
  16. +214 −0 tests/unit/checks/generictests/datasets/aws_ec2_limits_2.py
  17. +26 −0 tests/unit/checks/generictests/datasets/aws_elb_limits_1.py
  18. +26 −0 tests/unit/checks/generictests/datasets/aws_elb_limits_2.py
  19. +35 −0 tests/unit/checks/generictests/datasets/aws_elbv2_limits_1.py
  20. +37 −0 tests/unit/checks/generictests/datasets/aws_elbv2_limits_2.py
  21. +27 −0 tests/unit/checks/generictests/datasets/aws_glacier_limits_1.py
  22. +27 −0 tests/unit/checks/generictests/datasets/aws_glacier_limits_2.py
  23. +38 −0 tests/unit/checks/generictests/datasets/aws_rds_limits_1.py
  24. +38 −0 tests/unit/checks/generictests/datasets/aws_rds_limits_2.py
  25. +24 −0 tests/unit/checks/generictests/datasets/aws_s3_limits_1.py
  26. +24 −0 tests/unit/checks/generictests/datasets/aws_s3_limits_2.py
@@ -0,0 +1,11 @@
Title: aws_limits: Fixed parsing old agent data which does not contain information about region
Class: fix
Compatible: compat
Component: checks
Date: 1570521733
Edition: cre
Knowledge: doc
Level: 1
Version: 1.7.0i1


@@ -135,6 +135,19 @@ def _is_valid_aws_limits_perf_data(perfvar):
return True


def parse_aws_limit_line(line):
if len(line) == 5:
return tuple(line)
return tuple(line + [None])


def parse_aws_limits_generic(info):
parsed = []
for line in parse_aws(info):
parsed.append(parse_aws_limit_line(line) + (None,))
return parsed


def check_aws_limits(aws_service, params, parsed):
"""
Generic check for checking limits of AWS resource.
@@ -29,17 +29,12 @@ factory_settings['aws_cloudwatch_alarms_limits_default_levels'] = {
}


def parse_aws_cloudwatch_alarms_limits(info):
return [(resource_key, resource_title, limit, amount, None)
for resource_key, resource_title, limit, amount in parse_aws(info)]


def check_aws_cloudwatch_alarms_limits(item, params, parsed):
return check_aws_limits("cloudwatch_alarms", params, parsed)


check_info['aws_cloudwatch_alarms_limits'] = {
'parse_function': parse_aws_cloudwatch_alarms_limits,
'parse_function': parse_aws_limits_generic,
'inventory_function': discover_single,
'check_function': check_aws_cloudwatch_alarms_limits,
'service_description': 'AWS/Cloudwatch Alarms Limits',
@@ -37,7 +37,9 @@ factory_settings['aws_ebs_limits_default_levels'] = {

def parse_aws_ebs_limits(info):
parsed = []
for resource_key, resource_title, limit, amount, region in parse_aws(info):
for line in parse_aws(info):
resource_key, resource_title, limit, amount, region = parse_aws_limit_line(line)

if resource_key in [
"block_store_space_standard",
"block_store_space_io1",
@@ -41,11 +41,6 @@ factory_settings['aws_ec2_limits_default_levels'] = {
}


def parse_aws_ec2_limits(info):
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def _transform_ec2_limits(params):
transformed = {}
for k, v in params.iteritems():
@@ -66,7 +61,7 @@ def check_aws_ec2_limits(item, params, parsed):


check_info['aws_ec2_limits'] = {
'parse_function': parse_aws_ec2_limits,
'parse_function': parse_aws_limits_generic,
'inventory_function': discover_single,
'check_function': check_aws_ec2_limits,
'service_description': 'AWS/EC2 Limits',
@@ -31,17 +31,12 @@ factory_settings['aws_elb_limits_default_levels'] = {
}


def parse_aws_elb_limits(info):
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_elb_limits(item, params, parsed):
return check_aws_limits("elb", params, parsed)


check_info['aws_elb_limits'] = {
'parse_function': parse_aws_elb_limits,
'parse_function': parse_aws_limits_generic,
'inventory_function': discover_single,
'check_function': check_aws_elb_limits,
'service_description': 'AWS/ELB Limits',
@@ -37,17 +37,12 @@ factory_settings['aws_elbv2_limits_default_levels'] = {
}


def parse_aws_elbv2_limits(info):
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_elbv2_limits(item, params, parsed):
return check_aws_limits("elbv2", params, parsed)


check_info['aws_elbv2_limits'] = {
'parse_function': parse_aws_elbv2_limits,
'parse_function': parse_aws_limits_generic,
'inventory_function': discover_single,
'check_function': check_aws_elbv2_limits,
'service_description': 'AWS/ELBv2 Limits',
@@ -39,17 +39,12 @@ factory_settings['aws_glacier_limits_default_levels'] = {
}


def parse_aws_glacier_limits(info): # pylint: disable=function-redefined
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_glacier_limits(item, params, parsed):
return check_aws_limits("glacier", params, parsed)


check_info['aws_glacier_limits'] = {
'parse_function': parse_aws_glacier_limits,
'parse_function': parse_aws_limits_generic,
'inventory_function': discover_single,
'check_function': check_aws_glacier_limits,
'service_description': 'AWS/Glacier Limits',
@@ -45,7 +45,9 @@ factory_settings['aws_rds_limits_default_levels'] = {

def parse_aws_rds_limits(info):
parsed = []
for resource_key, resource_title, limit, amount, region in parse_aws(info):
for line in parse_aws(info):
resource_key, resource_title, limit, amount, region = parse_aws_limit_line(line)

if resource_key == "allocated_storage":
# Allocated Storage has unit TiB
factor = 1024**4 / 1000.0
@@ -29,17 +29,12 @@ factory_settings['aws_s3_limits_default_levels'] = {
}


def parse_aws_s3_limits(info): # pylint: disable=function-redefined
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_s3_limits(item, params, parsed):
return check_aws_limits("s3", params, parsed)


check_info['aws_s3_limits'] = {
'parse_function': parse_aws_s3_limits,
'parse_function': parse_aws_limits_generic,
'inventory_function': discover_single,
'check_function': check_aws_s3_limits,
'service_description': 'AWS/S3 Limits',
@@ -0,0 +1,27 @@
# -*- encoding: utf-8
# yapf: disable

checkname = 'aws_cloudwatch_alarms_limits'

info = [['[["cloudwatch_alarms",', '"TITEL",', '10,', '1]]']]

discovery = {'': [(None, {})]}

checks = {
'': [
(
None, {
'cloudwatch_alarms': (None, 80.0, 90.0)
}, [
(
0, 'No levels reached', [
(
u'aws_cloudwatch_alarms_cloudwatch_alarms', 1,
None, None, None, None
)
]
), (0, u'\nTITEL: 1 (of max. 10)', [])
]
)
]
}
@@ -0,0 +1,27 @@
# -*- encoding: utf-8
# yapf: disable

checkname = 'aws_cloudwatch_alarms_limits'

info = [['[["cloudwatch_alarms",', '"TITEL",', '10,', '1,', '"REGION"]]']]

discovery = {'': [(None, {})]}

checks = {
'': [
(
None, {
'cloudwatch_alarms': (None, 80.0, 90.0)
}, [
(
0, 'No levels reached', [
(
u'aws_cloudwatch_alarms_cloudwatch_alarms', 1,
None, None, None, None
)
]
), (0, u'\nTITEL: 1 (of max. 10) (Region REGION)', [])
]
)
]
}
@@ -0,0 +1,33 @@
# -*- encoding: utf-8
# yapf: disable

checkname = 'aws_ebs_limits'

info = [['[["block_store_snapshots",', '"TITLE",', '10,', '1]]']]

discovery = {'': [(None, {})]}

checks = {
'': [
(
None, {
'block_store_space_gp2': (None, 80.0, 90.0),
'block_store_space_sc1': (None, 80.0, 90.0),
'block_store_space_st1': (None, 80.0, 90.0),
'block_store_snapshots': (None, 80.0, 90.0),
'block_store_iops_io1': (None, 80.0, 90.0),
'block_store_space_standard': (None, 80.0, 90.0),
'block_store_space_io1': (None, 80.0, 90.0)
}, [
(
0, 'No levels reached', [
(
u'aws_ebs_block_store_snapshots', 1, None, None,
None, None
)
]
), (0, u'\nTITLE: 1 (of max. 10)', [])
]
)
]
}
@@ -0,0 +1,33 @@
# -*- encoding: utf-8
# yapf: disable

checkname = 'aws_ebs_limits'

info = [['[["block_store_snapshots",', '"TITLE",', '10,', '1,', '"REGION"]]']]

discovery = {'': [(None, {})]}

checks = {
'': [
(
None, {
'block_store_space_gp2': (None, 80.0, 90.0),
'block_store_space_sc1': (None, 80.0, 90.0),
'block_store_space_st1': (None, 80.0, 90.0),
'block_store_snapshots': (None, 80.0, 90.0),
'block_store_iops_io1': (None, 80.0, 90.0),
'block_store_space_standard': (None, 80.0, 90.0),
'block_store_space_io1': (None, 80.0, 90.0)
}, [
(
0, 'No levels reached', [
(
u'aws_ebs_block_store_snapshots', 1, None, None,
None, None
)
]
), (0, u'\nTITLE: 1 (of max. 10) (Region REGION)', [])
]
)
]
}

0 comments on commit 12c0195

Please sign in to comment.
You can’t perform that action at this time.