Skip to content
Permalink
Browse files

10322 graylog_jvm: New check to monitor heap space of graylog JVM

This check monitors the heap space of a graylog JVM. It outputs the used and
committed heap space. Needs the datasource "Check state of Graylog" to be
configured.

Change-Id: Iee856841d3c849d915148e91cb92eeeaa87c8684
  • Loading branch information...
makanakoeln committed Oct 9, 2019
1 parent 723ecec commit 5e6b01f5b7652ff18dc9c248adb1f28ac65997ae
@@ -0,0 +1,13 @@
Title: graylog_jvm: New check to monitor heap space of graylog JVM
Class: feature
Compatible: compat
Component: checks
Date: 1570626143
Edition: cre
Knowledge: undoc
Level: 1
Version: 1.7.0i1

This check monitors the heap space of a graylog JVM. It outputs the used and
committed heap space. Needs the datasource "Check state of Graylog" to be
configured.
@@ -0,0 +1,12 @@
title: Graylog: JVM
agents: graylog
catalog: app/graylog
license: GPL
distribution: check_mk
description:
This check monitors the heap space of a graylog JVM. It outputs the used and
committed heap space. Needs the datasource "Check state of Graylog" to be
configured.

inventory:
One service {"Graylog JVM"} will be created
@@ -0,0 +1,67 @@
#!/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 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.

# <<<graylog_jvm>>>
# {"jvm.memory.heap.init": 1073741824, "jvm.memory.heap.used": 357154208,
# "jvm.memory.heap.max": 1020067840, "jvm.memory.heap.committed": 1020067840,
# "jvm.memory.heap.usage": 0.35012789737592354}

import json


def check_graylog_jvm(_no_item, params, parsed):
if parsed is None:
return

has_mem_data = False
for key, metric_name in [
("used", "mem_heap"),
("committed", "mem_heap_committed"),
]:

mem_data = parsed.get("jvm.memory.heap.%s" % key)
if mem_data is None:
continue

has_mem_data = True
yield check_levels(mem_data,
metric_name,
params.get(key),
human_readable_func=get_bytes_human_readable,
infoname="%s heap space" % key.title())
if not has_mem_data:
yield 3, "No heap space data available"


check_info["graylog_jvm"] = {
"parse_function": parse_graylog_agent_data,
"check_function": check_graylog_jvm,
"inventory_function": discover_single,
"service_description": "Graylog JVM",
"has_perfdata": True,
"group": "graylog_jvm",
"includes": ["graylog.include"],
}
@@ -0,0 +1,69 @@
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@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.

from cmk.gui.i18n import _
from cmk.gui.valuespec import (
Dictionary,
Filesize,
Tuple,
)

from cmk.gui.plugins.wato import (
CheckParameterRulespecWithoutItem,
rulespec_registry,
RulespecGroupCheckParametersApplications,
)


def _parameter_valuespec_graylog_jvm():
return Dictionary(elements=[
("used",
Tuple(
title=_("Absolute levels for used heap space"),
elements=[
Filesize(title=_("Warning at")),
Filesize(title=_("Critical at")),
],
)),
("committed",
Tuple(
title=_("Absolute levels for committed heap space"),
elements=[
Filesize(title=_("Warning at")),
Filesize(title=_("Critical at")),
],
)),
],)


rulespec_registry.register(
CheckParameterRulespecWithoutItem(
check_group_name="graylog_jvm",
group=RulespecGroupCheckParametersApplications,
match_type="dict",
parameter_valuespec=_parameter_valuespec_graylog_jvm,
title=lambda: _("Graylog JVM"),
))
@@ -55,7 +55,7 @@ def main(argv=None):
GraylogSection(name="cluster_stats", uri="/system/cluster/stats"),
GraylogSection(name="cluster_traffic", uri="/system/cluster/traffic?days=1&daily=false"),
GraylogSection(name="failures", uri="/system/indexer/failures/count/?since=%s" % since),
GraylogSection(name="jvm", uri="/system/stats/jvm"),
GraylogSection(name="jvm", uri="/system/metrics/namespace/jvm.memory.heap"),
GraylogSection(name="messages", uri="/count/total"),
GraylogSection(name="nodes", uri="/cluster"),
GraylogSection(name="sidecars", uri="/sidecars"),
@@ -99,6 +99,23 @@ def handle_request(args, sections):
if node in value:
value[node].update({"inputstates": node_inputstates[node]})

if section.name == "jvm":
metric_data = value.get("metrics")
if metric_data is None:
continue

new_value = {}
for metric in value["metrics"]:

metric_value = metric.get("metric", {}).get("value")
metric_name = metric.get("full_name")
if metric_value is None or metric_name is None:
continue

new_value.update({metric_name: metric_value})

value = new_value

sys.stdout.write("%s\n" % json.dumps(value))


@@ -0,0 +1,34 @@
# -*- encoding: utf-8
# yapf: disable

checkname = 'graylog_jvm'

info = [
[
u'{"jvm.memory.heap.init": 1073741824, "jvm.memory.heap.used": 461934992, "jvm.memory.heap.max": 1020067840, "jvm.memory.heap.committed": 1020067840, "jvm.memory.heap.usage": 0.45284732435050595}'
]
]

discovery = {'': [(None, {})]}

checks = {
'': [
(
None, {}, [
(
0, 'Used heap space: 440.54 MB', [
('mem_heap', 461934992, None, None, None, None)
]
),
(
0, 'Committed heap space: 972.81 MB', [
(
'mem_heap_committed', 1020067840, None, None, None,
None
)
]
)
]
)
]
}

0 comments on commit 5e6b01f

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