Module: check_mk
Branch: master
Commit: f828d73d4c3f6be08f9b47bbc0ee91e1f8c2641f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f828d73d4c3f6b…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Dec 14 10:53:10 2018 +0100
aws_ec2_summary: Minor cleanup
Change-Id: I2dab830e1715ce7a0d3ba77f2e0a965b77556a3b
---
checks/aws_ec2_summary | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/checks/aws_ec2_summary b/checks/aws_ec2_summary
index c91ff8d..b97ea7b 100644
--- a/checks/aws_ec2_summary
+++ b/checks/aws_ec2_summary
@@ -32,20 +32,20 @@ def inventory_aws_ec2_summary(parsed):
def check_aws_ec2_summary(item, params, parsed):
instances_by_state = {}
+ long_output = []
for reservation in parsed:
for instance in reservation['Instances']:
- instances_by_state.setdefault(instance['State']['Name'],
[])\
- .append(instance['InstanceId'])
+ instance_id = instance['InstanceId']
+ instance_state = instance['State']['Name']
+ instances_by_state.setdefault(instance_state, []).append(instance_id)
+ long_output.append("Instance: %s, Status: %s" % (instance_id,
instance_state))
yield 0, "Instances: %s" % sum([len(v) for v in
instances_by_state.itervalues()])
-
- long_output = []
for instance_state, instances in instances_by_state.iteritems():
if instance_state == 'running':
state = 0
else:
state = 1
- long_output.append("%s: %s" % (instance_state, ",
".join(instances)))
yield state, "%s: %s" % (instance_state, len(instances))
if long_output: