I would like to integrate custom parameter for my SNMP check of check_MK. Unfornetally I dont find documentation and I dont understand how to setup rules to fit my check. I always receive a error message:
#The ruleset “checkgroup_parameters:defender_ft_stats_suspend” does not exist.
Do I need to add a rule in check_MK by the wato webinterface or do I need to fix my code? Thank you.
/opt/omd/sites/mysite/local/share/check_mk/checks/defender_ft_stats_suspend
#!/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.
factory_settings["defender_ft_stats_suspend_defaults"] = {
'ft_stats_suspend_tranfer_limits': (5,10),
}
def inventory_defender_ft_stats_suspend(info):
inventory = []
for r in range(len(info)):
inventory.append(("", None))
return tuple(inventory)
...
reduced code
...
def check_defender_ft_stats_suspend(item, params, info):
global state, perfdata
warn = params['ft_stats_suspend_tranfer_limits'][0]
error = params['ft_stats_suspend_tranfer_limits'][1]
stats_suspend_tranfer = int(info[0][2])
if (error <= stats_suspend_tranfer):
state = 2
elif (warn <= stats_suspend_tranfer):
state = 1
else:
state = 0
perfdata = [('ft_stats_suspend_tranfer_limits', stats_suspend_tranfer, warn, error, 0, 100)]
output = 'Current suspend transfer: {0}\n'.format(stats_suspend_tranfer)
return (state, output, perfdata)
# This check works on all SNMP hosts
check_info["defender_ft_stats_suspend"] = {
'check_function': check_defender_ft_stats_suspend,
'inventory_function': inventory_defender_ft_stats_suspend,
'service_description': 'Defender FT stats suspend',
'snmp_info': ('.x.x.x.x.x.x', sorted(mibs_ft)),
'group': 'defender_ft',
'default_levels_variable': 'defender_ft_stats_suspend_defaults',
'has_perfdata': True
}
/opt/omd/sites/mysite/local/share/check_mk/web/plugins/wato/defender_ft_stats_suspend
#!/usr/bin/python
import cmk.utils.defines as defines
group = "checkparams"
subgroup_defender_ft = _("defender_ft_stats_suspend")
register_check_parameters(
subgroup_defender_ft,
"defender_ft_stats_suspend",
_("Defender FT Stats Suspend"),
Dictionary(
elements=
[
('ft_stats_suspend_tranfer_limits',
Tuple(
title=_('Suspend FT Transfer'),
elements=[
Integer(title=_("Warning"), unit='', default_value=30),
Integer(title=_("Critical"), unit='', default_value=20),
]
),
),
],
optional_keys=[],
),
TextAscii(title = _("ascii title sm2")),
match_type="dict",
)
I added this snippet into: /etc/check_mk/conf.d/wato/rules.mk
checkgroup_parameters.setdefault('defender_ft_stats_suspend', [])
checkgroup_parameters['defender_ft_stats_suspend'] = [
( {'ft_stats_suspend_tranfer_limits': (50, 60)}, [], ALL_HOSTS ),
] + checkgroup_parameters['defender_ft_stats_suspend']