Module: check_mk
Branch: master
Commit: 0810f4741c401680c03c2bb83f7ed820af38a177
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0810f4741c4016…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Apr 10 12:00:44 2019 +0200
agent_aws, aws checks: Minor cleanup and a few bug fixes
- Wrong data structure of limits
- Wrong representation function of RDS limits
- Added missing perf data
- Adapted help text in agent_aws
- Exclude limit perf data including kind of dynamic names
- Sort long output of limits check
Change-Id: I0d3e792a7c0ac1286004fe4221251ac9183d586d
---
checks/aws.include | 28 +++++++++++++++---
checks/aws_ebs_limits | 2 +-
checks/aws_ec2_limits | 14 ++++-----
checks/aws_rds_limits | 5 +++-
cmk/gui/plugins/metrics/check_mk.py | 44 ++++++++++++++++++++++++++++
cmk/gui/plugins/wato/check_parameters/aws.py | 2 +-
cmk/special_agents/agent_aws.py | 4 +--
7 files changed, 81 insertions(+), 18 deletions(-)
diff --git a/checks/aws.include b/checks/aws.include
index 653de18..1f8b84e 100644
--- a/checks/aws.include
+++ b/checks/aws.include
@@ -85,6 +85,23 @@ def inventory_aws_generic_single(parsed, required_metrics):
return [(None, {})]
+# Some limit values have dynamic names, eg.
+# 'Rules of VPC security group %s' % SECURITY_GROUP
+# At the moment we exclude them in the performance data. If it's
+# a limit for a piggyback host, we do NOT exclude, eg. 'load_balancer_listeners'
+# and 'load_balancer_registered_instances' per load balancer piggyback host
+_exclude_aws_limits_perf_vars = [
+ 'vpc_sec_group_rules',
+ 'vpc_sec_groups',
+]
+
+
+def _is_valid_aws_limits_perf_data(perfvar):
+ if perfvar in _exclude_aws_limits_perf_vars:
+ return False
+ return True
+
+
def check_aws_limits(aws_service, params, parsed):
"""
Generic check for checking limits of AWS resource.
@@ -99,7 +116,7 @@ def check_aws_limits(aws_service, params, parsed):
if human_readable_func is None:
human_readable_func = lambda x: "%s" % x
- p_limit, (warn, crit) = params[resource_key]
+ p_limit, warn, crit = params[resource_key]
if p_limit is None:
limit_ref = limit
else:
@@ -107,8 +124,10 @@ def check_aws_limits(aws_service, params, parsed):
infotext = '%s: %s (of max. %s)' % (resource_title,
human_readable_func(amount),
human_readable_func(limit_ref))
- perfvar = "aws_%s_%s" % (aws_service, resource_key)
- perfdata.append((perfvar, amount))
+
+ if _is_valid_aws_limits_perf_data(resource_key):
+ perfvar = "aws_%s_%s" % (aws_service, resource_key)
+ perfdata.append((perfvar, amount))
if not limit_ref:
continue
@@ -129,5 +148,6 @@ def check_aws_limits(aws_service, params, parsed):
yield max_state, 'Levels reached: %s' % ",
".join(levels_reached), perfdata
else:
yield 0, 'No levels reached', perfdata
+
if long_output:
- yield 0, "\n%s" % "\n".join(long_output)
+ yield 0, "\n%s" % "\n".join(sorted(long_output))
diff --git a/checks/aws_ebs_limits b/checks/aws_ebs_limits
index 7e7afad..bd22299 100644
--- a/checks/aws_ebs_limits
+++ b/checks/aws_ebs_limits
@@ -52,7 +52,7 @@ def parse_aws_ebs_limits(info):
elif resource_key == "block_store_iops_io1":
human_readable_func = lambda x: "%s/s" % x
else:
- human_readable_func = None
+ human_readable_func = int
parsed.append((resource_key, resource_title, limit, amount,
human_readable_func))
return parsed
diff --git a/checks/aws_ec2_limits b/checks/aws_ec2_limits
index 7a65a8a..cd785d0 100644
--- a/checks/aws_ec2_limits
+++ b/checks/aws_ec2_limits
@@ -26,7 +26,7 @@
from cmk.special_agents.agent_aws import AWSEC2InstTypes
-_aws_ec2_limits_default_levels = {
+factory_settings['aws_ec2_limits_default_levels'] = {
'vpc_elastic_ip_addresses': (None, 80.0, 90.0),
'elastic_ip_addresses': (None, 80.0, 90.0),
'vpc_sec_group_rules': (None, 80.0, 90.0),
@@ -36,12 +36,9 @@ _aws_ec2_limits_default_levels = {
'active_spot_fleet_requests': (None, 80.0, 90.0),
'spot_fleet_total_target_capacity': (None, 80.0, 90.0),
'running_ondemand_instances_total': (None, 80.0, 90.0),
+ 'running_ondemand_instances':
+ [(inst_type, (None, 80.0, 90.0)) for inst_type in AWSEC2InstTypes],
}
-_aws_ec2_limits_default_levels.update({
- 'running_ondemand_instances_%s' % inst_type: (None, 80.0, 90.0) for inst_type
in AWSEC2InstTypes
-})
-
-factory_settings['aws_ec2_limits_default_levels'] =
_aws_ec2_limits_default_levels
def parse_aws_ec2_limits(info):
@@ -55,9 +52,8 @@ def _transform_ec2_limits(params):
if isinstance(v, tuple):
transformed[k] = v
elif isinstance(v, list):
- # As we get from agent
- for inst_type, levels in v:
- transformed['running_ondemand_instances_%s' % inst_type] =
levels
+ transformed.update(
+ {'running_ondemand_instances_%s' % inst_type: levels for
inst_type, levels in v})
return transformed
diff --git a/checks/aws_rds_limits b/checks/aws_rds_limits
index c3fa675..f0a7a33 100644
--- a/checks/aws_rds_limits
+++ b/checks/aws_rds_limits
@@ -51,7 +51,10 @@ def parse_aws_rds_limits(info):
factor = 1024**4 / 1000
limit = limit * factor
amount = amount * factor
- parsed.append(resource_key, resource_title, limit, amount,
get_bytes_human_readable)
+ human_readable_f = get_bytes_human_readable
+ else:
+ human_readable_f = int
+ parsed.append((resource_key, resource_title, limit, amount, human_readable_f))
return parsed
diff --git a/cmk/gui/plugins/metrics/check_mk.py b/cmk/gui/plugins/metrics/check_mk.py
index 2187ca5..6482bf8 100644
--- a/cmk/gui/plugins/metrics/check_mk.py
+++ b/cmk/gui/plugins/metrics/check_mk.py
@@ -5071,6 +5071,50 @@ metric_info['aws_request_latency'] = {
'color': '21/a',
}
+metric_info['aws_ec2_vpc_elastic_ip_addresses'] = {
+ 'title': _('VPC Elastic IP Addresses'),
+ 'unit': 'count',
+ 'color': '11/a',
+}
+
+metric_info['aws_ec2_elastic_ip_addresses'] = {
+ 'title': _('Elastic IP Addresses'),
+ 'unit': 'count',
+ 'color': '13/a',
+}
+
+metric_info['aws_ec2_spot_inst_requests'] = {
+ 'title': _('Spot Instance Requests'),
+ 'unit': 'count',
+ 'color': '15/a',
+}
+
+metric_info['aws_ec2_active_spot_fleet_requests'] = {
+ 'title': _('Active Spot Fleet Requests'),
+ 'unit': 'count',
+ 'color': '21/a',
+}
+
+metric_info['aws_ec2_spot_fleet_total_target_capacity'] = {
+ 'title': _('Spot Fleet Requests Total Target Capacity'),
+ 'unit': 'count',
+ 'color': '23/a',
+}
+
+metric_info['aws_ec2_running_ondemand_instances_total'] = {
+ 'title': _('Total Running On-Demand Instances'),
+ 'unit': 'count',
+ 'color': '25/a',
+}
+
+from cmk.special_agents.agent_aws import AWSEC2InstTypes
+for inst_type in AWSEC2InstTypes:
+ metric_info['aws_ec2_running_ondemand_instances_%s' % inst_type] = {
+ 'title': _('Total Running On-Demand %s Instances') % inst_type,
+ 'unit': 'count',
+ 'color': '11/a',
+ }
+
metric_info['get_requests'] = {
'title': _('GET Requests'),
'unit': '1/s',
diff --git a/cmk/gui/plugins/wato/check_parameters/aws.py
b/cmk/gui/plugins/wato/check_parameters/aws.py
index 87061e3..863d401 100644
--- a/cmk/gui/plugins/wato/check_parameters/aws.py
+++ b/cmk/gui/plugins/wato/check_parameters/aws.py
@@ -167,7 +167,7 @@ def _vs_limits(resource, default_limit, vs_limit_cls=None):
Tuple(
title=_("Set levels"),
elements=[
- vs_limit,
+ Alternative(elements=[FixedValue(None, totext="Limit from AWS
API"), vs_limit]),
Percentage(title=_("Warning at"), default_value=80.0),
Percentage(title=_("Critical at"), default_value=90.0),
]),
diff --git a/cmk/special_agents/agent_aws.py b/cmk/special_agents/agent_aws.py
index 259f2d6..5857e12 100644
--- a/cmk/special_agents/agent_aws.py
+++ b/cmk/special_agents/agent_aws.py
@@ -2435,9 +2435,9 @@ def parse_arguments(argv):
)
parser.add_argument(
- "--access-key-id", required=True, help="The access key for your
AWS account.")
+ "--access-key-id", required=True, help="The access key ID for your
AWS account.")
parser.add_argument(
- "--secret-access-key", required=True, help="The secret key for
your AWS account.")
+ "--secret-access-key", required=True, help="The secret access key
for your AWS account.")
parser.add_argument(
"--regions",
nargs='+',