GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / aws_rds_summary
bloba93b66cfa48399106e3aea8e7e45cdfc6de99ad1
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2019 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.
28 def parse_aws_rds_summary(info):
29 try:
30 return {instance['DBName']: instance for instance in parse_aws(info)}
31 except IndexError:
32 return {}
35 # .--summary-------------------------------------------------------------.
36 # | |
37 # | ___ _ _ _ __ ___ _ __ ___ __ _ _ __ _ _ |
38 # | / __| | | | '_ ` _ \| '_ ` _ \ / _` | '__| | | | |
39 # | \__ \ |_| | | | | | | | | | | | (_| | | | |_| | |
40 # | |___/\__,_|_| |_| |_|_| |_| |_|\__,_|_| \__, | |
41 # | |___/ |
42 # '----------------------------------------------------------------------'
45 def check_aws_rds_summary(item, params, parsed):
46 instances_by_classes = {}
47 for instance in parsed.itervalues():
48 instance_class = instance['DBInstanceClass']
49 instances_by_classes.setdefault(instance_class, []).append(instance)
51 class_infos = []
52 for instance_class, instances in instances_by_classes.iteritems():
53 class_infos.append("%s: %s" % (instance_class, len(instances)))
54 yield 0, ", ".join(class_infos)
57 check_info['aws_rds_summary'] = {
58 'parse_function': parse_aws_rds_summary,
59 'inventory_function': discover_single,
60 'check_function': check_aws_rds_summary,
61 'service_description': 'AWS/RDS Summary',
62 'includes': ['aws.include'],
66 # .--DB status-----------------------------------------------------------.
67 # | ____ ____ _ _ |
68 # | | _ \| __ ) ___| |_ __ _| |_ _ _ ___ |
69 # | | | | | _ \ / __| __/ _` | __| | | / __| |
70 # | | |_| | |_) | \__ \ || (_| | |_| |_| \__ \ |
71 # | |____/|____/ |___/\__\__,_|\__|\__,_|___/ |
72 # | |
73 # '----------------------------------------------------------------------'
76 @get_parsed_item_data
77 def check_aws_rds_summary_db(item, params, data):
78 db_id = data['DBInstanceIdentifier']
79 pre_info = ""
80 if db_id is not None:
81 pre_info = "[%s] " % db_id
82 yield 0, '%sStatus: %s' % (pre_info, data['DBInstanceStatus'])
84 multi_az = data.get('MultiAZ')
85 if multi_az is not None:
86 if multi_az:
87 multi_az_readable = "yes"
88 else:
89 multi_az_readable = "no"
90 yield 0, 'Multi AZ: %s' % multi_az_readable
92 zone = data.get('AvailabilityZone')
93 if zone is not None:
94 region = zone[:-1]
95 zone_info = zone[-1]
96 yield 0, 'Availability zone: %s (%s)' % (AWSRegions[region], zone_info)
99 check_info['aws_rds_summary.db_status'] = {
100 'inventory_function': lambda p: inventory_aws_generic(p, ['DBInstanceStatus']),
101 'check_function': check_aws_rds_summary_db,
102 'service_description': 'AWS/RDS %s Info',
103 'includes': ['aws.include'],