Skip to content
Permalink
Browse files

7864 aws_glacier_limits and aws_glacier_summary: New checks to monito…

…r AWS/Glacier limits and to overview over all AWS/Glacier vaults

increased cache interval to 1 day
fixed aws agent tests

Change-Id: I66fdec0445b70de387c9af75aeafeb7003fc704b
  • Loading branch information...
Axel Dimroth
Axel Dimroth committed Jul 25, 2019
1 parent 8c5ab3f commit 1bbcf5d06b0092993dd46bac9b70d8dadedb2fa0
@@ -0,0 +1,10 @@
Title: aws_glacier_limits and aws_glacier_summary: New checks to monitor AWS/Glacier limits and to overview over all AWS/Glacier vaults
Level: 1
Component: checks
Compatible: compat
Edition: cre
Version: 1.7.0i1
Date: 1564062870
Class: feature


@@ -0,0 +1,16 @@
title: AWS/Glacier Vault
agents: aws
catalog: cloud/aws
license: GPL
distribution: check_mk
description:
This check monitors the archives of AWS/Glacier vaults and reports
the number of archives and size of the vault.
To make this check work you have to configure the related
special agent {Amazon Web Services (AWS)}.

There are no default levels set for the vault size. Upper
levels are configurable.

inventory:
One service per vault will be created.
@@ -0,0 +1,16 @@
title: AWS/Glacier Summary
agents: aws
catalog: cloud/aws
license: GPL
distribution: check_mk
description:
This check monitors all AWS Glacier vaults and reports
a summary of their states.
To make this check work you have to configure the related
special agent {Amazon Web Services (AWS)}.

There are no default levels set for the total vault size. Upper
levels are configurable.

inventory:
One summary service is created.
@@ -0,0 +1,19 @@
title: AWS/Glacier Limits
agents: aws
catalog: cloud/aws
license: GPL
distribution: check_mk
description:
This check monitors the AWS/Glacier limits, ie. the number of
allowed vaults withing a region.
To make this check work you have to configure the related
special agent {Amazon Web Services (AWS)}.

Default levels are set to 80, 90 percent and the default max.
value of 1000. These levels are configurable.

If limits are enabled all vaults are fetched regardless of
possibly configured restriction to names or tags.

inventory:
One service will be created.
@@ -145,7 +145,7 @@ def check_aws_limits(aws_service, params, parsed):
levels_reached = set()
max_state = 0
perfdata = []
for resource_key, resource_title, limit, amount, human_readable_func in parsed:
for resource_key, resource_title, limit, amount, region, human_readable_func in parsed:
if human_readable_func is None:
human_readable_func = lambda x: "%s" % x

@@ -155,9 +155,9 @@ def check_aws_limits(aws_service, params, parsed):
else:
limit_ref = p_limit

infotext = '%s: %s (of max. %s)' % (resource_title, human_readable_func(amount),
human_readable_func(limit_ref))

infotext = '%s: %s (of max. %s)%s' % (resource_title, human_readable_func(amount),
human_readable_func(limit_ref),
" (Region %s)" % region if region else "")
perfvar = "aws_%s_%s" % (aws_service, resource_key)
if _is_valid_aws_limits_perf_data(resource_key):
perfdata.append((perfvar, amount))
@@ -37,7 +37,7 @@ factory_settings['aws_ebs_limits_default_levels'] = {

def parse_aws_ebs_limits(info):
parsed = []
for resource_key, resource_title, limit, amount in parse_aws(info):
for resource_key, resource_title, limit, amount, region in parse_aws(info):
if resource_key in [
"block_store_space_standard",
"block_store_space_io1",
@@ -53,7 +53,7 @@ def parse_aws_ebs_limits(info):
human_readable_func = lambda x: "%s/s" % x
else:
human_readable_func = int
parsed.append((resource_key, resource_title, limit, amount, human_readable_func))
parsed.append((resource_key, resource_title, limit, amount, region, human_readable_func))
return parsed


@@ -42,8 +42,8 @@ factory_settings['aws_ec2_limits_default_levels'] = {


def parse_aws_ec2_limits(info):
return [(resource_key, resource_title, limit, amount, None)
for resource_key, resource_title, limit, amount in parse_aws(info)]
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def _transform_ec2_limits(params):
@@ -32,8 +32,8 @@ factory_settings['aws_elb_limits_default_levels'] = {


def parse_aws_elb_limits(info):
return [(resource_key, resource_title, limit, amount, None)
for resource_key, resource_title, limit, amount in parse_aws(info)]
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_elb_limits(item, params, parsed):
@@ -38,8 +38,8 @@ factory_settings['aws_elbv2_limits_default_levels'] = {


def parse_aws_elbv2_limits(info):
return [(resource_key, resource_title, limit, amount, None)
for resource_key, resource_title, limit, amount in parse_aws(info)]
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_elbv2_limits(item, params, parsed):
@@ -0,0 +1,130 @@
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2019 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at https://checkmk.com/.
#
# 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_glacier(info): # pylint: disable=function-redefined
parsed = parse_aws(info)
parsed_by_vault = {}
for vault in parsed:
parsed_by_vault[vault["VaultName"]] = vault
return parsed_by_vault


#.
# .--Glacier archives----------------------------------------------------.
# | ____ _ _ |
# | / ___| | __ _ ___(_) ___ _ __ |
# | | | _| |/ _` |/ __| |/ _ \ '__| |
# | | |_| | | (_| | (__| | __/ | |
# | \____|_|\__,_|\___|_|\___|_| |
# | _ _ |
# | __ _ _ __ ___| |__ (_)_ _____ ___ |
# | / _` | '__/ __| '_ \| \ \ / / _ \/ __| |
# | | (_| | | | (__| | | | |\ V / __/\__ \ |
# | \__,_|_| \___|_| |_|_| \_/ \___||___/ |
# | |
# '----------------------------------------------------------------------'


def inventory_aws_glacier(parsed):
for vault_name in parsed:
yield vault_name, {}


@get_parsed_item_data
def check_aws_glacier_archives(item, params, parsed):
vault_size = parsed.get('SizeInBytes', 0)
yield check_levels(vault_size,
"aws_glacier_vault_size",
params.get('vault_size_levels', (None, None)),
human_readable_func=get_bytes_human_readable,
infoname='Vault size')

num_archives = parsed.get('NumberOfArchives', 0)
yield 0, 'Number of archives: %s' % int(num_archives), [('aws_glacier_num_archives',
num_archives)]

tag_infos = []
for key, value in parsed.get('Tagging', {}).items():
tag_infos.append("%s: %s" % (key, value))
if tag_infos:
yield 0, '[Tags]: %s' % ", ".join(tag_infos)


check_info['aws_glacier'] = {
'parse_function': parse_aws_glacier,
'inventory_function': inventory_aws_glacier,
'check_function': check_aws_glacier_archives,
'service_description': 'AWS/Glacier Vault: %s',
'has_perfdata': True,
'includes': ['aws.include'],
'group': 'aws_glacier_vault_archives',
}

#.
# .--Glacier summary-----------------------------------------------------.
# | ____ _ _ |
# | / ___| | __ _ ___(_) ___ _ __ |
# | | | _| |/ _` |/ __| |/ _ \ '__| |
# | | |_| | | (_| | (__| | __/ | |
# | \____|_|\__,_|\___|_|\___|_| |
# | ___ _ _ _ __ ___ _ __ ___ __ _ _ __ _ _ |
# | / __| | | | '_ ` _ \| '_ ` _ \ / _` | '__| | | | |
# | \__ \ |_| | | | | | | | | | | | (_| | | | |_| | |
# | |___/\__,_|_| |_| |_|_| |_| |_|\__,_|_| \__, | |
# | |___/ |
# '----------------------------------------------------------------------


def check_aws_glacier_summary(item, params, parsed):
sum_size = 0
largest_vault = None
largest_vault_size = 0
for vault_name in parsed:
vault_size = parsed.get(vault_name).get('SizeInBytes', 0)
sum_size += vault_size
if vault_size >= largest_vault_size:
largest_vault = vault_name
largest_vault_size = vault_size
yield check_levels(sum_size,
"aws_glacier_total_vault_size",
params.get('vault_size_levels', (None, None)),
human_readable_func=get_bytes_human_readable,
infoname='Total size')

if largest_vault:
yield 0, 'Largest vault: %s (%s)' % \
(largest_vault, get_bytes_human_readable(largest_vault_size)), [('aws_glacier_largest_vault_size', \
largest_vault_size)]


check_info['aws_glacier.summary'] = {
'inventory_function': discover_single,
'check_function': check_aws_glacier_summary,
'service_description': 'AWS/Glacier Summary',
'has_perfdata': True,
'group': 'aws_glacier_vaults',
}
@@ -0,0 +1,60 @@
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2019 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at https://checkmk.com/.
#
# 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.

#.
# .--Glacier limits------------------------------------------------------.
# | ____ _ _ _ _ _ _ |
# | / ___| | __ _ ___(_) ___ _ __ | (_)_ __ ___ (_) |_ ___ |
# | | | _| |/ _` |/ __| |/ _ \ '__| | | | '_ ` _ \| | __/ __| |
# | | |_| | | (_| | (__| | __/ | | | | | | | | | | |_\__ \ |
# | \____|_|\__,_|\___|_|\___|_| |_|_|_| |_| |_|_|\__|___/ |
# | |
# '----------------------------------------------------------------------'

factory_settings['aws_glacier_limits_default_levels'] = {
'number_of_vaults': (None, 80.0, 90.0),
}


def parse_aws_glacier_limits(info): # pylint: disable=function-redefined
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_glacier_limits(item, params, parsed):
return check_aws_limits("glacier", params, parsed)


check_info['aws_glacier_limits'] = {
'parse_function': parse_aws_glacier_limits,
'inventory_function': discover_single,
'check_function': check_aws_glacier_limits,
'service_description': 'AWS/Glacier Limits',
'includes': ['aws.include'],
'group': 'aws_glacier_limits',
'default_levels_variable': 'aws_glacier_limits_default_levels',
'has_perfdata': True,
}
@@ -45,7 +45,7 @@ factory_settings['aws_rds_limits_default_levels'] = {

def parse_aws_rds_limits(info):
parsed = []
for resource_key, resource_title, limit, amount in parse_aws(info):
for resource_key, resource_title, limit, amount, region in parse_aws(info):
if resource_key == "allocated_storage":
# Allocated Storage has unit TiB
factor = 1024**4 / 1000
@@ -54,7 +54,7 @@ def parse_aws_rds_limits(info):
human_readable_f = get_bytes_human_readable
else:
human_readable_f = int
parsed.append((resource_key, resource_title, limit, amount, human_readable_f))
parsed.append((resource_key, resource_title, limit, amount, region, human_readable_f))
return parsed


@@ -30,8 +30,8 @@ factory_settings['aws_s3_limits_default_levels'] = {


def parse_aws_s3_limits(info): # pylint: disable=function-redefined
return [(resource_key, resource_title, limit, amount, None)
for resource_key, resource_title, limit, amount in parse_aws(info)]
return [(resource_key, resource_title, limit, amount, region, None)
for resource_key, resource_title, limit, amount, region in parse_aws(info)]


def check_aws_s3_limits(item, params, parsed):
@@ -4971,8 +4971,38 @@ def register_fireye_metrics():
'color': '11/a',
}

metric_info['aws_glacier_number_of_vaults'] = {
'title': _('Number of vaults'),
'unit': 'count',
'color': '11/a',
}

metric_info['aws_glacier_num_archives'] = {
'title': _('Number of archives'),
'unit': 'count',
'color': '21/a',
}

metric_info['aws_glacier_vault_size'] = {
'title': _('Vault size'),
'unit': 'bytes',
'color': '15/a',
}

metric_info['aws_glacier_total_vault_size'] = {
'title': _('Total size of all vaults'),
'unit': 'bytes',
'color': '15/a',
}

metric_info['aws_glacier_largest_vault_size'] = {
'title': _('Largest vault size'),
'unit': 'bytes',
'color': '21/a',
}

metric_info['aws_num_objects'] = {
'title': _('Numer of objects'),
'title': _('Number of objects'),
'unit': 'count',
'color': '21/a',
}

0 comments on commit 1bbcf5d

Please sign in to comment.
You can’t perform that action at this time.