Module: check_mk
Branch: master
Commit: 010a3b486919e9f254e637515a23e7c13f4d19be
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=010a3b486919e9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Feb 15 11:43:15 2019 +0100
aws_s3, aws_s3.summary: Upper levels for the (total) bucket size are configurable now
Change-Id: I7b5e220ea3859225dca73dc674fabd867283dc3d
---
checkman/aws_s3 | 3 ++
checkman/aws_s3.summary | 3 ++
checks/aws_s3 | 21 +++++---
cmk/gui/plugins/wato/check_parameters/aws.py | 72 ++++++++++++++++++++++++++++
4 files changed, 93 insertions(+), 6 deletions(-)
diff --git a/checkman/aws_s3 b/checkman/aws_s3
index d470566..9fae280 100644
--- a/checkman/aws_s3
+++ b/checkman/aws_s3
@@ -10,5 +10,8 @@ description:
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 bucket size. Upper
+ levels are configurable.
+
inventory:
One service per bucket will be created.
diff --git a/checkman/aws_s3.summary b/checkman/aws_s3.summary
index b7aa661..556fa89 100644
--- a/checkman/aws_s3.summary
+++ b/checkman/aws_s3.summary
@@ -9,5 +9,8 @@ description:
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 bucket size. Upper
+ levels are configurable.
+
inventory:
One summary service is created.
diff --git a/checks/aws_s3 b/checks/aws_s3
index fc032a1..0c25461 100644
--- a/checks/aws_s3
+++ b/checks/aws_s3
@@ -70,12 +70,14 @@ def check_aws_s3_objects(item, params, metrics):
storage_infos.append(
"%s: %s" % (aws_s3_storage_mapping[storage_type],
get_bytes_human_readable(value)))
sum_size = sum(bucket_sizes.values())
+ yield check_levels(
+ sum_size,
+ "aws_bucket_size",
+ params.get('bucket_size_levels', (None, None)),
+ human_readable_func=get_bytes_human_readable,
+ infoname='Bucket size')
if storage_infos:
- storage_infos_str = " (%s)" % ", ".join(storage_infos)
- else:
- storage_infos_str = ""
- yield (0, 'Bucket size: %s%s' % (get_bytes_human_readable(sum_size),
storage_infos_str),
- [('aws_bucket_size', sum_size)])
+ yield 0, ", ".join(storage_infos)
num_objects = sum(metrics['numberofobjects'].values())
yield 0, 'Number of objects: %s' % int(num_objects),
[('aws_num_objects', num_objects)]
@@ -98,6 +100,7 @@ check_info['aws_s3'] = {
'service_description': 'AWS/S3 Objects %s',
'has_perfdata': True,
'includes': ['aws.include'],
+ 'group': 'aws_s3_buckets_objects',
}
#.
@@ -121,7 +124,12 @@ def check_aws_s3_summary(item, params, parsed):
if bucket_size >= largest_bucket_size:
largest_bucket = bucket_name
largest_bucket_size = bucket_size
- yield 0, 'Total size: %s' % get_bytes_human_readable(sum_size),
[('aws_bucket_size', sum_size)]
+ yield check_levels(
+ sum_size,
+ "aws_bucket_size",
+ params.get('bucket_size_levels', (None, None)),
+ human_readable_func=get_bytes_human_readable,
+ infoname='Total size')
if largest_bucket:
yield 0, 'Largest bucket: %s (%s)' % \
@@ -133,4 +141,5 @@ check_info['aws_s3.summary'] = {
'check_function': check_aws_s3_summary,
'service_description': 'AWS/S3 Summary',
'has_perfdata': True,
+ 'group': 'aws_s3_buckets',
}
diff --git a/cmk/gui/plugins/wato/check_parameters/aws.py
b/cmk/gui/plugins/wato/check_parameters/aws.py
index 0a96bc2..7048690 100644
--- a/cmk/gui/plugins/wato/check_parameters/aws.py
+++ b/cmk/gui/plugins/wato/check_parameters/aws.py
@@ -35,6 +35,7 @@ from cmk.gui.valuespec import (
Age,
FixedValue,
TextAscii,
+ Filesize,
)
from cmk.gui.plugins.wato import (
RulespecGroupCheckParametersApplications,
@@ -44,6 +45,77 @@ from cmk.gui.plugins.wato import (
)
+def _vs_s3_buckets():
+ return ('bucket_size_levels',
+ Alternative(
+ title=_("Upper levels for the bucket size"),
+ style="dropdown",
+ elements=[
+ Tuple(
+ title=_("Set levels"),
+ elements=[
+ Filesize(title=_("Warning at")),
+ Filesize(title=_("Critical at")),
+ ]),
+ Tuple(
+ title=_("No levels"),
+ elements=[
+ FixedValue(None, totext=""),
+ FixedValue(None, totext=""),
+ ]),
+ ]))
+
+
+(a)rulespec_registry.register
+class RulespecCheckgroupParametersAwsS3BucketsObjects(CheckParameterRulespecWithItem):
+ @property
+ def group(self):
+ return RulespecGroupCheckParametersApplications
+
+ @property
+ def check_group_name(self):
+ return "aws_s3_buckets_objects"
+
+ @property
+ def title(self):
+ return _("AWS/S3 Bucket Objects")
+
+ @property
+ def match_type(self):
+ return "dict"
+
+ @property
+ def parameter_valuespec(self):
+ return Dictionary(elements=[_vs_s3_buckets()])
+
+ @property
+ def item_spec(self):
+ return TextAscii(title=_("The bucket name"))
+
+
+(a)rulespec_registry.register
+class RulespecCheckgroupParametersAwsS3Buckets(CheckParameterRulespecWithoutItem):
+ @property
+ def group(self):
+ return RulespecGroupCheckParametersApplications
+
+ @property
+ def check_group_name(self):
+ return "aws_s3_buckets"
+
+ @property
+ def title(self):
+ return _("AWS/S3 Buckets")
+
+ @property
+ def match_type(self):
+ return "dict"
+
+ @property
+ def parameter_valuespec(self):
+ return Dictionary(elements=[_vs_s3_buckets()])
+
+
def _vs_burst_balance():
return ('burst_balance_levels_lower',
Alternative(