Module: check_mk
Branch: master
Commit: ce4e768ca69a9c4fa473ffff21425277c6800a7f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ce4e768ca69a9c…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Dec 20 10:37:41 2018 +0100
aws_elb_summary, aws_elb_health: Checks for AWS/ELB (elastic load balancer)
Change-Id: Iec15456770c2a91c1f238aef8de66b9372804fbc
---
checkman/aws_elb_health | 15 ++++++++++
checkman/aws_elb_summary | 12 ++++++++
checks/aws_elb_health | 72 ++++++++++++++++++++++++++++++++++++++++++++++
checks/aws_elb_summary | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 173 insertions(+)
diff --git a/checkman/aws_elb_health b/checkman/aws_elb_health
new file mode 100644
index 0000000..e8dc160
--- /dev/null
+++ b/checkman/aws_elb_health
@@ -0,0 +1,15 @@
+title: AWS ELB Health
+agents: aws
+catalog: cloud/aws
+license: GPL
+distribution: check_mk
+description:
+ This check monitors all AWS ELB and reports a summary of their states.
+ To make this check work you have to configure the related special agent
+ {{Amazon Web Services (AWS)}}.
+
+ If the elastic load balancer is "in service" the check stats is OK,
+ if it is "out of service" the check state is WARN, otherwise UNKNOWN.
+
+inventory:
+ One service is created.
diff --git a/checkman/aws_elb_summary b/checkman/aws_elb_summary
new file mode 100644
index 0000000..d5a2596
--- /dev/null
+++ b/checkman/aws_elb_summary
@@ -0,0 +1,12 @@
+title: AWS ELB Summary
+agents: aws
+catalog: cloud/aws
+license: GPL
+distribution: check_mk
+description:
+ This check monitors all AWS ELB and reports a summary of their states.
+ To make this check work you have to configure the related special agent
+ {{Amazon Web Services (AWS)}}.
+
+inventory:
+ One summary service is created.
diff --git a/checks/aws_elb_health b/checks/aws_elb_health
new file mode 100644
index 0000000..99570c2
--- /dev/null
+++ b/checks/aws_elb_health
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+AWSELBHealthMap = {
+ "InService": "in service",
+ "OutOfService": "out of service",
+ "Unknown": "unknown",
+}
+
+
+def parse_aws_elb_health(info):
+ try:
+ return parse_aws(info)[-1]
+ except IndexError:
+ return {}
+
+
+def inventory_aws_elb_health(parsed):
+ if parsed:
+ return [(None, {})]
+
+
+def check_aws_elb_health(item, params, parsed):
+ state_readable = AWSELBHealthMap[parsed['State']]
+ if state_readable == "in service":
+ state = 0
+ elif state_readable == "out of service":
+ state = 1
+ else:
+ state = 3
+ yield state, 'Status: %s' % state_readable
+ yield 0, 'Instance: %s' % parsed['InstanceId']
+
+ reason_code = parsed['ReasonCode']
+ if reason_code not in [None, "", "N/A"]:
+ yield 0, 'Reason: %s' % reason_code
+
+ description = parsed['Description']
+ if description not in [None, "", "N/A"]:
+ yield 0, 'Description: %s' % description
+
+
+check_info['aws_elb_health'] = {
+ 'parse_function': parse_aws_elb_health,
+ 'inventory_function': inventory_aws_elb_health,
+ 'check_function': check_aws_elb_health,
+ 'service_description': 'AWS/ELB Health ',
+ 'includes': ['aws.include'],
+}
diff --git a/checks/aws_elb_summary b/checks/aws_elb_summary
new file mode 100644
index 0000000..49e7ed6
--- /dev/null
+++ b/checks/aws_elb_summary
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+AWSAvailabilityZoneMap = {
+ "us-east-1": "Virginia",
+ "us-west-1": "N. California",
+ "us-west-2": "Oregon",
+ "eu-west-1": "Ireland",
+ "eu-central-1": "Frankfurt",
+ "ap-southeast-1": "Singapore",
+ "ap-southeast-2": "Sydney",
+ "ap-northeast-1": "Tokyo",
+ "sa-east-1": "Sao Paulo",
+}
+
+
+def inventory_aws_elb_summary(parsed):
+ if parsed:
+ return [(None, {})]
+
+
+def check_aws_elb_summary(item, params, parsed):
+ yield 0, "Balancers: %s" % len(parsed)
+
+ balancers_by_avail_zone = {}
+ long_output = []
+ for row in parsed:
+ balancer_name = row['LoadBalancerName']
+ avail_zones_txt = []
+ for avail_zone in row['AvailabilityZones']:
+ avail_zone_readable = "%s (%s)" %
(AWSAvailabilityZoneMap[avail_zone[:-1]],
+ avail_zone[-1])
+ balancers_by_avail_zone.setdefault(avail_zone_readable,
[]).append(balancer_name)
+ avail_zones_txt.append(avail_zone_readable)
+ long_output.append("Balancer: %s, Availability zones: %s"\
+ % (balancer_name, ", ".join(avail_zones_txt)))
+
+ for avail_zone, balancers in balancers_by_avail_zone.iteritems():
+ yield 0, "%s: %s" % (avail_zone, len(balancers))
+
+ if long_output:
+ yield 0, '\n%s' % '\n'.join(long_output)
+
+
+check_info['aws_elb_summary'] = {
+ 'parse_function': parse_aws,
+ 'inventory_function': inventory_aws_elb_summary,
+ 'check_function': check_aws_elb_summary,
+ 'service_description': 'AWS/ELB Summary',
+ 'includes': ['aws.include'],
+}