Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / aws_elb_summary
blob49e7ed6216fca426c7599e4e7978a6c65e9e445f
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2018 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 AWSAvailabilityZoneMap = {
28 "us-east-1": "Virginia",
29 "us-west-1": "N. California",
30 "us-west-2": "Oregon",
31 "eu-west-1": "Ireland",
32 "eu-central-1": "Frankfurt",
33 "ap-southeast-1": "Singapore",
34 "ap-southeast-2": "Sydney",
35 "ap-northeast-1": "Tokyo",
36 "sa-east-1": "Sao Paulo",
40 def inventory_aws_elb_summary(parsed):
41 if parsed:
42 return [(None, {})]
45 def check_aws_elb_summary(item, params, parsed):
46 yield 0, "Balancers: %s" % len(parsed)
48 balancers_by_avail_zone = {}
49 long_output = []
50 for row in parsed:
51 balancer_name = row['LoadBalancerName']
52 avail_zones_txt = []
53 for avail_zone in row['AvailabilityZones']:
54 avail_zone_readable = "%s (%s)" % (AWSAvailabilityZoneMap[avail_zone[:-1]],
55 avail_zone[-1])
56 balancers_by_avail_zone.setdefault(avail_zone_readable, []).append(balancer_name)
57 avail_zones_txt.append(avail_zone_readable)
58 long_output.append("Balancer: %s, Availability zones: %s"\
59 % (balancer_name, ", ".join(avail_zones_txt)))
61 for avail_zone, balancers in balancers_by_avail_zone.iteritems():
62 yield 0, "%s: %s" % (avail_zone, len(balancers))
64 if long_output:
65 yield 0, '\n%s' % '\n'.join(long_output)
68 check_info['aws_elb_summary'] = {
69 'parse_function': parse_aws,
70 'inventory_function': inventory_aws_elb_summary,
71 'check_function': check_aws_elb_summary,
72 'service_description': 'AWS/ELB Summary',
73 'includes': ['aws.include'],