Cleanup config.nodes_of
[check_mk.git] / checks / aws_ebs_summary
blobf35db2cacf588a82b96f6606beb34c1260cc00f5
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 AWSEBSStorageTypes = {
28 "gp2": "General Purpose SSD",
29 "io1": "Provisioned IOPS SSD",
30 "st1": "Throughput Optimized HDD",
31 "sc1": "Cold HDD",
35 def parse_aws_summary(info):
36 parsed = {}
37 for row in parse_aws(info):
38 inst = parsed.setdefault(row['VolumeId'], row)
39 type_ = row['VolumeType']
40 inst.setdefault('type_readable', AWSEBSStorageTypes.get(type_, "unknown[%s]" % type_))
41 return parsed
44 # .--summary-------------------------------------------------------------.
45 # | |
46 # | ___ _ _ _ __ ___ _ __ ___ __ _ _ __ _ _ |
47 # | / __| | | | '_ ` _ \| '_ ` _ \ / _` | '__| | | | |
48 # | \__ \ |_| | | | | | | | | | | | (_| | | | |_| | |
49 # | |___/\__,_|_| |_| |_|_| |_| |_|\__,_|_| \__, | |
50 # | |___/ |
51 # '----------------------------------------------------------------------'
54 def check_aws_ebs_summary(item, params, parsed):
55 stores_by_state = {}
56 stores_by_type = {}
57 long_output = []
58 for volume_id, row in parsed.iteritems():
59 stores_by_state.setdefault(row['State'], []).append(volume_id)
60 stores_by_type.setdefault(row['VolumeType'], []).append(volume_id)
61 long_output.append(
62 "Volume: %s, Status: %s, Type: %s, Encrypted: %s, Creation time: %s"\
63 % (volume_id, row['State'], row['VolumeType'], row['Encrypted'], row['CreateTime'])
66 yield 0, 'Stores: %s' % len(parsed)
67 for state, stores in stores_by_state.iteritems():
68 yield 0, '%s: %s' % (state, len(stores))
69 for type_, stores in stores_by_type.iteritems():
70 yield 0, '%s: %s' % (AWSEBSStorageTypes.get(type_, "unknown[%s]" % type_), len(stores))
71 if long_output:
72 yield 0, '\n%s' % '\n'.join(long_output)
75 check_info['aws_ebs_summary'] = {
76 'parse_function': parse_aws_summary,
77 'inventory_function': discover_single,
78 'check_function': check_aws_ebs_summary,
79 'service_description': 'AWS/EBS Summary',
80 'includes': ['aws.include'],
84 # .--health--------------------------------------------------------------.
85 # | _ _ _ _ |
86 # | | |__ ___ __ _| | |_| |__ |
87 # | | '_ \ / _ \/ _` | | __| '_ \ |
88 # | | | | | __/ (_| | | |_| | | | |
89 # | |_| |_|\___|\__,_|_|\__|_| |_| |
90 # | |
91 # '----------------------------------------------------------------------'
94 @get_parsed_item_data
95 def check_aws_ebs_summary_health(item, params, ebs_data):
96 metrics = ebs_data['VolumeStatus']
97 ebs_status = metrics["Status"]
98 yield 0 if ebs_status.lower() == 'ok' else 2, "Status: %s" % ebs_status
99 for row in metrics['Details']:
100 yield 0, "%s: %s" % (row['Name'], row['Status'])
103 check_info['aws_ebs_summary.health'] = {
104 'inventory_function': lambda p:\
105 inventory_aws_generic(p, ['VolumeStatus']),
106 'check_function': check_aws_ebs_summary_health,
107 'service_description': 'AWS/EBS Health %s',
108 'includes': ['aws.include'],