Module: check_mk
Branch: master
Commit: 940a570e29a6b22993543dc2e929c4de03cb0bbb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=940a570e29a6b2…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Feb 11 10:49:24 2019 +0100
agent_aws: Do not assign EC2 summary to piggyback hosts
Change-Id: I42a906b527f0ebea8a598e9a63e2c7997e3ae478
---
agents/special/agent_aws | 5 +----
checks/aws_ec2_summary | 25 ++++++++++++-------------
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/agents/special/agent_aws b/agents/special/agent_aws
index 6fdb871..0c8adb5 100755
--- a/agents/special/agent_aws
+++ b/agents/special/agent_aws
@@ -448,10 +448,7 @@ class EC2Summary(AWSSectionGeneric):
}, raw_content.cache_timestamp)
def _create_results(self, computed_content):
- return [
- AWSSectionResult(instance_name, [instance])
- for instance_name, instance in computed_content.content.iteritems()
- ]
+ return [AWSSectionResult("", computed_content.content.values())]
class EC2SecurityGroups(AWSSectionGeneric):
diff --git a/checks/aws_ec2_summary b/checks/aws_ec2_summary
index b6684b1..182d83e 100644
--- a/checks/aws_ec2_summary
+++ b/checks/aws_ec2_summary
@@ -38,20 +38,19 @@ def _extract_aws_ec2_tags(metrics):
def check_aws_ec2_summary(item, params, parsed):
instances_by_state = {}
long_output = []
- for instances in parsed:
- for instance_name, instance in instances.iteritems():
- instance_id = instance['InstanceId']
- instance_state = instance['State']['Name']
- instances_by_state.setdefault(instance_state, []).append(instance_id)
+ for instance in parsed:
+ instance_private_dns_name = instance['PrivateDnsName']
+ instance_id = instance['InstanceId']
+ instance_state = instance['State']['Name']
+ instances_by_state.setdefault(instance_state, []).append(instance_id)
- prefix = ""
- if instance_name != instance_id:
- prefix = "[%s] " % instance_name
- long_output_info = ["%s%s: %s" % (prefix, instance_id,
instance_state)]
- tags = _extract_aws_ec2_tags(instance)
- if tags:
- long_output_info.append("[Tags] %s" % tags)
- long_output.append(", ".join(long_output_info))
+ long_output_info = [
+ "[%s] %s: %s" % (instance_id, instance_private_dns_name,
instance_state)
+ ]
+ tags = _extract_aws_ec2_tags(instance)
+ if tags:
+ long_output_info.append("[Tags] %s" % tags)
+ long_output.append(", ".join(long_output_info))
yield 0, "Instances: %s" % sum([len(v) for v in
instances_by_state.itervalues()])
for instance_state, instances in instances_by_state.iteritems():