Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit 75dc9c99 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent 275cc92b
No related branches found
No related tags found
No related merge requests found
...@@ -51,16 +51,32 @@ def discovery_cisco_asyncos_bandwidth(section: CiscoAsyncosBandwidth) -> Discove ...@@ -51,16 +51,32 @@ def discovery_cisco_asyncos_bandwidth(section: CiscoAsyncosBandwidth) -> Discove
def check_cisco_asyncos_bandwidth(params, section: CiscoAsyncosBandwidth) -> CheckResult: def check_cisco_asyncos_bandwidth(params, section: CiscoAsyncosBandwidth) -> CheckResult:
yield from check_levels( yield from check_levels(
section.bandwidth_now, section.bandwidth_now * 8,
label='Current bandwidth', label='Current bandwidth',
levels_upper=params.get('upper', None), levels_upper=params.get('upper', None),
levels_lower=params.get('lower', None), levels_lower=params.get('lower', None),
metric_name='bandwith_now', metric_name='bandwith_now',
render_func=render.networkbandwidth,
unit='bits/s'
)
yield from check_levels(
section.bandwidth_hour * 8,
label='last hour',
# levels_upper=params.get('upper', None),
# levels_lower=params.get('lower', None),
# metric_name='bandwith_now',
render_func=render.networkbandwidth
)
yield from check_levels(
section.bandwidth_day * 8,
label='last day',
#levels_upper=params.get('upper', None),
#levels_lower=params.get('lower', None),
#metric_name='bandwith_now',
render_func=render.networkbandwidth render_func=render.networkbandwidth
) )
yield Result(state=State.OK, # yield Result(state=State.OK, summary='last hour: %s, last day: %s' % (section.bandwidth_hour, section.bandwidth_day))
summary='last hour: %s, last day: %s' % (section.bandwidth_hour, section.bandwidth_day))
register.snmp_section( register.snmp_section(
......
...@@ -185,6 +185,7 @@ def parse_cisco_asyncos_license(string_table: List[StringTable]) -> Mapping[str, ...@@ -185,6 +185,7 @@ def parse_cisco_asyncos_license(string_table: List[StringTable]) -> Mapping[str,
def discovery_cisco_asyncos_license(section: Mapping[str, CiscoAsyncosLicense]) -> DiscoveryResult: def discovery_cisco_asyncos_license(section: Mapping[str, CiscoAsyncosLicense]) -> DiscoveryResult:
yield Service() yield Service()
# Parameters({'expire': (400, 360), 'features_ignore': ['Data Loss Prevention']}) # Parameters({'expire': (400, 360), 'features_ignore': ['Data Loss Prevention']})
def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicense]) -> CheckResult: def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicense]) -> CheckResult:
features_ignore = params.get('features_ignore', []) features_ignore = params.get('features_ignore', [])
...@@ -194,10 +195,11 @@ def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicens ...@@ -194,10 +195,11 @@ def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicens
if section[license].perpetual: if section[license].perpetual:
yield Result(state=State.OK, notice='%s is perpetual (will not expire)' % license) yield Result(state=State.OK, notice='%s is perpetual (will not expire)' % license)
elif license in features_ignore: elif license in features_ignore:
yield Result(state=State.OK, notice='%s will expire at %s (%s days). Feature ignored!' % (license, section[license].expiredate, section[license].daysuntilexpire)) yield Result(state=State.OK, notice='%s will expire at %s (%s days). Feature ignored!' % (
license, section[license].expiredate, section[license].daysuntilexpire))
ignore_count += 1 ignore_count += 1
elif section[license].secondsuntilexpire == 0: elif section[license].secondsuntilexpire == 0:
yield Result(state=State.CRIT, notice='%s has expired or is not licensed' % license) yield Result(state=State.CRIT, notice='%s has expired or is not licensed' % license)
else: else:
if section[license].daysuntilexpire < crit: if section[license].daysuntilexpire < crit:
state = State.CRIT state = State.CRIT
...@@ -206,10 +208,12 @@ def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicens ...@@ -206,10 +208,12 @@ def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicens
else: else:
state = State.OK state = State.OK
yield Result(state=state, notice='%s will expire at %s (%s days)' % (license, section[license].expiredate, section[license].daysuntilexpire)) yield Result(state=state, notice='%s will expire at %s (%s days)' % (
license, section[license].expiredate, section[license].daysuntilexpire))
yield Result(state=State.OK, summary='%d/%d Features found/ignored' % (len(section.keys()), ignore_count)) yield Result(state=State.OK, summary='%d/%d Features found/ignored' % (len(section.keys()), ignore_count))
register.snmp_section( register.snmp_section(
name='cisco_asyncos_license', name='cisco_asyncos_license',
parse_function=parse_cisco_asyncos_license, parse_function=parse_cisco_asyncos_license,
......
#!/usr/bin/python #!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*- # -*- coding: utf-8 -*-
# #
# Rewriten by: Th.L. # License: GNU General Public License v2
# Date: 19-02-2020
# #
# 2020-05-14: added wato oprion to ignore items # Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2020-02-19
# #
# check_mk is free software; you can redistribute it and/or modify it # 2020-05-14: added wato oprion to ignore items
# under the terms of the GNU General Public License as published by # 2021-03-25: rewrite for CMK2.0
# 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-
# ails. 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.
# #
# #
# sample snmpwalk # sample snmpwalk
...@@ -144,116 +137,176 @@ ...@@ -144,116 +137,176 @@
# ASYNCOS-MAIL-MIB::updateFailures.14 = Counter32: 0 # ASYNCOS-MAIL-MIB::updateFailures.14 = Counter32: 0
# ASYNCOS-MAIL-MIB::updateFailures.15 = Counter32: 0 # ASYNCOS-MAIL-MIB::updateFailures.15 = Counter32: 0
# #
# sample info from typing import Mapping, List, NamedTuple
#
# [[u'File Reputation', u'1', u'0'], from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
# [u'IronPort Anti-Spam', u'10', u'0'], DiscoveryResult,
# [u'McAfee', u'1', u'0'], CheckResult,
# [u'Sophos Anti-Virus', u'1', u'0'], StringTable,
# [u'amp', u'1', u'0'], )
# [u'content_scanner', u'1', u'0'],
# [u'enrollment_client', u'1', u'0'],
# [u'geo_countries', u'1', u'0'],
# [u'howto', u'0', u'0'],
# [u'openssh_key', u'0', u'0'],
# [u'repeng', u'0', u'0'],
# [u'sdr_client', u'0', u'0'],
# [u'smart_agent', u'0', u'0'],
# [u'support_request', u'1', u'0'],
# [u'timezones', u'1', u'0']
# ]
#
factory_settings['cisco_asyncos_update_default_levels'] = { from cmk.base.plugins.agent_based.agent_based_api.v1 import (
'failedLevel': (5, 10), register,
'features_ignore': [] Service,
} check_levels,
Result,
SNMPTree,
contains,
State,
render,
)
def inventory_cisco_asyncos_update(info): class CiscoAsyncosUpdate(NamedTuple):
if len(info) > 0: updates: int
return [(None, None)] updatefailures: int
# [[
# ['File Reputation', '6', '38'],
# ['IronPort Anti-Spam', '12', '9'],
# ['McAfee', '6', '25'],
# ['Sophos Anti-Virus', '6', '17'],
# ['amp', '1', '0'],
# ['content_scanner', '1', '0'],
# ['enrollment_client', '1', '0'],
# ['geo_countries', '1', '0'],
# ['howto', '0', '0'],
# ['openssh_key', '0', '0'],
# ['repeng', '0', '0'],
# ['sdr_client', '0', '0'],
# ['smart_agent', '0', '0'],
# ['support_request', '1', '0'],
# ['timezones', '1', '0']
# ]]
def parse_cisco_asyncos_update(string_table: List[StringTable]) -> Mapping[str, CiscoAsyncosUpdate]:
features = {}
for feature, updates, update_failures in string_table[0]:
features.update({feature: CiscoAsyncosUpdate(
updates=int(updates),
updatefailures=int(update_failures)
) })
return features
def check_cisco_asyncos_update(_no_item, params, info): # {
if len(info) > 0: # 'File Reputation': CiscoAsyncosUpdate(updates=6, updatefailures=38),
infotext = '' # 'IronPort Anti-Spam': CiscoAsyncosUpdate(updates=12, updatefailures=9),
longoutput = '' # 'McAfee': CiscoAsyncosUpdate(updates=6, updatefailures=25),
perfdata = [] # 'Sophos Anti-Virus': CiscoAsyncosUpdate(updates=6, updatefailures=17),
failedItemsWarn = [] # 'amp': CiscoAsyncosUpdate(updates=1, updatefailures=0),
failedItemsCrit = [] # 'content_scanner': CiscoAsyncosUpdate(updates=1, updatefailures=0),
failedWarn, failedCrit = params.get('failedLevel') # 'enrollment_client': CiscoAsyncosUpdate(updates=1, updatefailures=0),
features_ignore = params['features_ignore'] # 'geo_countries': CiscoAsyncosUpdate(updates=1, updatefailures=0),
lastState = 1 # 'howto': CiscoAsyncosUpdate(updates=0, updatefailures=0),
# 'openssh_key': CiscoAsyncosUpdate(updates=0, updatefailures=0),
for line in info: # 'repeng': CiscoAsyncosUpdate(updates=0, updatefailures=0),
name, passed, failed = line # 'sdr_client': CiscoAsyncosUpdate(updates=0, updatefailures=0),
longoutput += '\n%s: %s/%s passed/failed attempt(s)' % (name, passed, failed) # 'smart_agent': CiscoAsyncosUpdate(updates=0, updatefailures=0),
# read counters # 'support_request': CiscoAsyncosUpdate(updates=1, updatefailures=0),
passedLast = get_item_state('cisco_asyncos_update_%s_passedLast' % name) # 'timezones': CiscoAsyncosUpdate(updates=1, updatefailures=0)
failedLast = get_item_state('cisco_asyncos_update_%s_failedLast' % name) # }
failedAttempts = get_item_state('cisco_asyncos_update_%s_failedAttempts' % name) def discovery_cisco_asyncos_update(section:Mapping[str, CiscoAsyncosUpdate])-> DiscoveryResult:
yield Service()
if (passedLast == None) or (failedLast == None) or (failedAttempts == None): # or (lastState == None): def check_cisco_asyncos_update(params, section:Mapping[str, CiscoAsyncosUpdate]) -> CheckResult:
# init counters features_ignore = params.get('features_ignore', [])
set_item_state('cisco_asyncos_update_%s_passedLast' % name, passed) warn, crit = params.get('failedLevel')
set_item_state('cisco_asyncos_update_%s_failedLast' % name, failed) ignore_count = 0
set_item_state('cisco_asyncos_update_%s_failedAttempts' % name, 0) for feature in section.keys():
else: if feature in features_ignore:
set_item_state('cisco_asyncos_update_%s_passedLast' % name, passed) yield Result(state=State.OK, notice='Feature %s: %d/%d updates/update failures. Feature ignored!' % (feature, section[feature].updates, section[feature].updatefailures))
set_item_state('cisco_asyncos_update_%s_failedLast' % name, failed) ignore_count += 1
passedLast = int(passedLast) else:
failedLast = int(failedLast) yield Result(state=State.OK, notice='Feature %s: %d/%d updates/update failures. Feature ignored!' % (feature, section[feature].updates, section[feature].updatefailures))
failedAttempts = int(failedAttempts)
failed = int(failed)
passed = int(passed)
# reset counter if overrun
if failed < failedLast:
set_item_state('cisco_asyncos_update_%s_failedLast' % name, failed)
failedLast = failed
if passed < passedLast:
set_item_state('cisco_asyncos_update_%s_passedLast' % name, passed)
passedLast = passed
if passed > passedLast: yield Result(state=State.OK, summary='%d/%d Features found/ignored' % (len(section.keys()), ignore_count))
# rest error counter after passed update attempt
set_item_state('cisco_asyncos_update_%s_failedAttempts' % name, 0)
else:
failedAttempts = failedAttempts + failed - failedLast
set_item_state('cisco_asyncos_update_%s_failedAttempts' % name, failedAttempts)
if name not in features_ignore:
if failedAttempts >= failedCrit:
failedItemsCrit.append(name)
lastState = -1
elif failedAttempts >= failedWarn:
failedItemsWarn.append(name)
lastState = -1
perfdata.append((name.replace(' ', '_'), lastState, None, None, -1, 1)) # if len(info) > 0:
# infotext = ''
# longoutput = ''
# perfdata = []
# failedItemsWarn = []
# failedItemsCrit = []
# failedWarn, failedCrit = params.get('failedLevel')
# features_ignore = params['features_ignore']
# lastState = 1
#
# for line in info:
# name, passed, failed = line
# longoutput += '\n%s: %s/%s passed/failed attempt(s)' % (name, passed, failed)
# # read counters
# passedLast = get_item_state('cisco_asyncos_update_%s_passedLast' % name)
# failedLast = get_item_state('cisco_asyncos_update_%s_failedLast' % name)
# failedAttempts = get_item_state('cisco_asyncos_update_%s_failedAttempts' % name)
#
# if (passedLast == None) or (failedLast == None) or (failedAttempts == None): # or (lastState == None):
# # init counters
# set_item_state('cisco_asyncos_update_%s_passedLast' % name, passed)
# set_item_state('cisco_asyncos_update_%s_failedLast' % name, failed)
# set_item_state('cisco_asyncos_update_%s_failedAttempts' % name, 0)
# else:
# set_item_state('cisco_asyncos_update_%s_passedLast' % name, passed)
# set_item_state('cisco_asyncos_update_%s_failedLast' % name, failed)
# passedLast = int(passedLast)
# failedLast = int(failedLast)
# failedAttempts = int(failedAttempts)
# failed = int(failed)
# passed = int(passed)
# # reset counter if overrun
# if failed < failedLast:
# set_item_state('cisco_asyncos_update_%s_failedLast' % name, failed)
# failedLast = failed
# if passed < passedLast:
# set_item_state('cisco_asyncos_update_%s_passedLast' % name, passed)
# passedLast = passed
#
# if passed > passedLast:
# # rest error counter after passed update attempt
# set_item_state('cisco_asyncos_update_%s_failedAttempts' % name, 0)
# else:
# failedAttempts = failedAttempts + failed - failedLast
# set_item_state('cisco_asyncos_update_%s_failedAttempts' % name, failedAttempts)
# if name not in features_ignore:
# if failedAttempts >= failedCrit:
# failedItemsCrit.append(name)
# lastState = -1
# elif failedAttempts >= failedWarn:
# failedItemsWarn.append(name)
# lastState = -1
#
# perfdata.append((name.replace(' ', '_'), lastState, None, None, -1, 1))
#
# infotext += '%d item(s) found' % len(info)
# if len(failedItemsCrit) > 0:
# yield 2, '%d failed item(s) (%s), failed attempts >= %d' % (len(failedItemsCrit), ', '.join(failedItemsCrit), failedCrit)
# if len(failedItemsWarn) > 0:
# yield 1, '%d failed item(s) (%s), failed attempts >= %d' % (len(failedItemsWarn), ', '.join(failedItemsWarn), failedWarn)
#
# yield 0, infotext + longoutput, perfdata
infotext += '%d item(s) found' % len(info)
if len(failedItemsCrit) > 0:
yield 2, '%d failed item(s) (%s), failed attempts >= %d' % (len(failedItemsCrit), ', '.join(failedItemsCrit), failedCrit)
if len(failedItemsWarn) > 0:
yield 1, '%d failed item(s) (%s), failed attempts >= %d' % (len(failedItemsWarn), ', '.join(failedItemsWarn), failedWarn)
yield 0, infotext + longoutput, perfdata
register.snmp_section(
name='cisco_asyncos_update',
parse_function=parse_cisco_asyncos_update,
fetch=[
SNMPTree(
base='.1.3.6.1.4.1.15497.1.1.1.13.1', # ASYNCOS-MAIL-MIB::updateEntry
oids=[
'2', # updateServiceName -> A textual name for an update entry
'3', # updates -> The number of successful attempts that have occurred when updating a service
'4', # updateFailures -> "The number of failed attempts that have occurred when updating a service
]
),
],
detect=contains('.1.3.6.1.2.1.1.1.0', 'AsyncOS'),
)
check_info['cisco_asyncos_update'] = { register.check_plugin(
'check_function': check_cisco_asyncos_update, name='cisco_asyncos_update',
'inventory_function': inventory_cisco_asyncos_update, service_name='Update',
'group': 'cisco_asyncos_update', discovery_function=discovery_cisco_asyncos_update,
'service_description': 'Update', check_function=check_cisco_asyncos_update,
'has_perfdata': True, check_default_parameters={'failedLevel': (5, 10)},
'snmp_info': ('.1.3.6.1.4.1.15497.1.1.1.13.1', [ # ASYNCOS-MAIL-MIB::updateEntry check_ruleset_name='cisco_asyncos_update',
'2', # updateServiceName --> A textual name for an update entry )
'3', # updates --> The number of successful attempts that have occurred when updating a service
'4', # updateFailures --> "The number of failed attempts that have occurred when updating a service
]),
'default_levels_variable': 'cisco_asyncos_update_default_levels',
'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.1.0').find('AsyncOS') != -1,
# 'snmp_scan_function': scan_cisco_asyncos,
# 'includes': ['cisco_asyncos.include'],
}
No preview for this file type
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
'cisco_asyncos_messageage.py', 'cisco_asyncos_messageage.py',
'cisco_asyncos_queue.py', 'cisco_asyncos_queue.py',
'cisco_asyncos_resources.py', 'cisco_asyncos_resources.py',
'cisco_asyncos_license.py'], 'cisco_asyncos_license.py',
'checks': ['cisco_asyncos_update'], 'cisco_asyncos_update.py'],
'web': ['plugins/wato/cisco_asyncos_license.py', 'web': ['plugins/wato/cisco_asyncos_license.py',
'plugins/wato/cisco_asyncos_queue.py', 'plugins/wato/cisco_asyncos_queue.py',
'plugins/wato/cisco_asyncos_update.py', 'plugins/wato/cisco_asyncos_update.py',
......
#!/usr/bin/python #!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*- # -*- coding: utf-8 -*-
# #
# #
register_check_parameters( from cmk.gui.i18n import _
subgroup_applications, from cmk.gui.valuespec import (
'cisco_asyncos_queue', Dictionary,
_('Cisco AsyncOS queue'), Integer,
Dictionary( TextAscii,
# help=_(''), ListOfStrings,
elements=[ Tuple,
('levels',
Tuple(
title=_('Levels for nuber of messages in work queue'),
elements=[
Integer(title=_('Warning'), default_value=50, unit=_('# of messages')),
Integer(title=_('Critical'), default_value=100, unit=_('# of messages')),
])),
],
),
None,
match_type='dict',
) )
from cmk.gui.plugins.wato import (
CheckParameterRulespecWithItem,
rulespec_registry,
RulespecGroupCheckParametersNetworking,
)
def _parameter_valuespec_cisco_asyncos_queue():
return Dictionary(elements=[
('levels',
Tuple(
title=_('Levels for nuber of messages in work queue'),
elements=[
Integer(title=_('Warning'), default_value=50, unit=_('# of messages')),
Integer(title=_('Critical'), default_value=100, unit=_('# of messages')),
])),
])
rulespec_registry.register(
CheckParameterRulespecWithItem(
check_group_name='cisco_asyncos_queue',
group=RulespecGroupCheckParametersNetworking,
item_spec=lambda: TextAscii(title=_('Cisco AsyncOS queue'), ),
match_type='dict',
parameter_valuespec=_parameter_valuespec_cisco_asyncos_queue,
title=lambda: _('Cisco AsyncOS queue'),
))
#!/usr/bin/python #!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*- # -*- coding: utf-8 -*-
# #
# #
register_check_parameters( from cmk.gui.i18n import _
subgroup_applications, from cmk.gui.valuespec import (
'cisco_asyncos_update', Dictionary,
_('Cisco AsyncOS update'), Integer,
Dictionary( TextAscii,
# help=_(''), ListOfStrings,
elements=[ Tuple,
('features_ignore',
ListOfStrings(
title=_('update features to ignore'),
orientation='vertical',
help=_('there will be no warning/critical if this features are not updated'
'Examples: geo_countries, timezones, etc.'),
)
),
('failedLevel',
Tuple(
title=_('Levels for failed attempts'),
elements=[
Integer(title=_('Warning'), default_value=5, unit=_('# of failed attempts')),
Integer(title=_('Critical'), default_value=10, unit=_('# of failed attempts')),
])),
],
),
None,
match_type='dict',
) )
from cmk.gui.plugins.wato import (
CheckParameterRulespecWithItem,
rulespec_registry,
RulespecGroupCheckParametersNetworking,
)
def _parameter_valuespec_cisco_asyncos_license():
return Dictionary(elements=[
('features_ignore',
ListOfStrings(
title=_('Update features to ignore'),
orientation='vertical',
help=_('there will be no warning/critical if this features are not updated'
'Examples: geo_countries, timezones, etc.'),
)
),
('failedLevel',
Tuple(
title=_('Levels for failed attempts'),
elements=[
Integer(title=_('Warning'), default_value=5, unit=_('# of failed attempts')),
Integer(title=_('Critical'), default_value=10, unit=_('# of failed attempts')),
])),
])
rulespec_registry.register(
CheckParameterRulespecWithItem(
check_group_name='cisco_asyncos_update',
group=RulespecGroupCheckParametersNetworking,
item_spec=lambda: TextAscii(title=_('Cisco AsyncOS update'), ),
match_type='dict',
parameter_valuespec=_parameter_valuespec_cisco_asyncos_update,
title=lambda: _('Cisco AsyncOS update'),
))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment