Module: check_mk
Branch: master
Commit: 6b9405952aa1eaeb0eb382aaf20deb9d96033254
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6b9405952aa1ea…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Dec 14 12:59:59 2018 +0100
6828 aws_ebs_health, aws_ebs_summary: New checks for AWS/EBS
Change-Id: Iab5da0b339be49ed26be31462d3c69a600042a96
---
.werks/6828 | 10 +++++++
checkman/aws_ebs_health | 14 +++++++++
checkman/aws_ebs_summary | 13 +++++++++
checks/aws_ebs_health | 46 +++++++++++++++++++++++++++++
checks/aws_ebs_summary | 76 ++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 159 insertions(+)
diff --git a/.werks/6828 b/.werks/6828
new file mode 100644
index 0000000..f06b900
--- /dev/null
+++ b/.werks/6828
@@ -0,0 +1,10 @@
+Title: aws_ebs_health, aws_ebs_summary: New checks for AWS/EBS
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1544788776
+Class: feature
+
+
diff --git a/checkman/aws_ebs_health b/checkman/aws_ebs_health
new file mode 100644
index 0000000..39069cc
--- /dev/null
+++ b/checkman/aws_ebs_health
@@ -0,0 +1,14 @@
+title: AWS EBS Health
+agents: aws
+catalog: cloud/aws
+license: GPL
+distribution: check_mk
+description:
+ This check monitors health of AWS elastic block storages.
+ To make this check work you have to configure the related
+ special agent {{Amazon Web Services (AWS)}}.
+ If the EBS status is OK the check returns OK otherwise CRIT.
+ Details of the single status checks are also reported.
+
+inventory:
+ One service will be created.
diff --git a/checkman/aws_ebs_summary b/checkman/aws_ebs_summary
new file mode 100644
index 0000000..156dd99
--- /dev/null
+++ b/checkman/aws_ebs_summary
@@ -0,0 +1,13 @@
+title: AWS EBS Summary
+agents: aws
+catalog: cloud/aws
+license: GPL
+distribution: check_mk
+description:
+ This check monitors all AWS EBS 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_ebs_health b/checks/aws_ebs_health
new file mode 100644
index 0000000..37d2a0d
--- /dev/null
+++ b/checks/aws_ebs_health
@@ -0,0 +1,46 @@
+#!/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.
+
+
+def parse_aws_health(info):
+ return {k: v for row in parse_aws(info) for k, v in row.iteritems()}
+
+
+@get_parsed_item_data
+def check_aws_ebs_health(item, params, metrics):
+ ebs_status = metrics["Status"]
+ yield 0 if ebs_status.lower() == 'ok' else 2, "Status: %s" %
ebs_status
+ for row in metrics['Details']:
+ yield 0, "%s: %s" % (row['Name'], row['Status'])
+
+
+check_info['aws_ebs_health'] = {
+ 'parse_function': parse_aws_health,
+ 'inventory_function': discover(),
+ 'check_function': check_aws_ebs_health,
+ 'service_description': 'AWS/EBS Health %s',
+ 'includes': ['aws.include'],
+}
diff --git a/checks/aws_ebs_summary b/checks/aws_ebs_summary
new file mode 100644
index 0000000..ea818e4
--- /dev/null
+++ b/checks/aws_ebs_summary
@@ -0,0 +1,76 @@
+#!/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.
+
+AWSEBSStorageTypes = {
+ "gp2": "General Purpose SSD",
+ "io1": "Provisioned IOPS SSD",
+ "st1": "Throughput Optimized HDD",
+ "sc1": "Cold HDD",
+}
+
+
+def parse_aws_summary(info):
+ parsed = {}
+ for row in parse_aws(info):
+ inst = parsed.setdefault(row['VolumeId'], row)
+ type_ = row['VolumeType']
+ inst.setdefault('type_readable', AWSEBSStorageTypes.get(type_,
"unknown[%s]" % type_))
+ return parsed
+
+
+def inventory_aws_ebs_summary(parsed):
+ if parsed:
+ return [(None, {})]
+
+
+def check_aws_ebs_summary(item, params, parsed):
+ stores_by_state = {}
+ stores_by_type = {}
+ long_output = []
+ for volume_id, row in parsed.iteritems():
+ stores_by_state.setdefault(row['State'], []).append(volume_id)
+ stores_by_type.setdefault(row['VolumeType'], []).append(volume_id)
+ long_output.append(
+ "Volume: %s, Status: %s, Type: %s, Encrypted: %s, Creation time:
%s"\
+ % (volume_id, row['State'], row['VolumeType'],
row['Encrypted'], row['CreateTime'])
+ )
+
+ yield 0, 'Stores: %s' % len(parsed)
+ for state, stores in stores_by_state.iteritems():
+ yield 0, '%s: %s' % (state, len(stores))
+ for type_, stores in stores_by_type.iteritems():
+ yield 0, '%s: %s' % (AWSEBSStorageTypes.get(type_,
"unknown[%s]" % type_), len(stores))
+ if long_output:
+ yield 0, '\n%s' % '\n'.join(long_output)
+
+
+check_info['aws_ebs_summary'] = {
+ 'parse_function': parse_aws_summary,
+ 'inventory_function': inventory_aws_ebs_summary,
+ 'check_function': check_aws_ebs_summary,
+ 'service_description': 'AWS/EBS Summary',
+ 'includes': ['aws.include'],
+}