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
def check_cisco_asyncos_bandwidth(params, section: CiscoAsyncosBandwidth) -> CheckResult:
yield from check_levels(
section.bandwidth_now,
section.bandwidth_now * 8,
label='Current bandwidth',
levels_upper=params.get('upper', None),
levels_lower=params.get('lower', None),
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
)
yield Result(state=State.OK,
summary='last hour: %s, last day: %s' % (section.bandwidth_hour, section.bandwidth_day))
# yield Result(state=State.OK, summary='last hour: %s, last day: %s' % (section.bandwidth_hour, section.bandwidth_day))
register.snmp_section(
......
......@@ -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:
yield Service()
# Parameters({'expire': (400, 360), 'features_ignore': ['Data Loss Prevention']})
def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicense]) -> CheckResult:
features_ignore = params.get('features_ignore', [])
......@@ -194,10 +195,11 @@ def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicens
if section[license].perpetual:
yield Result(state=State.OK, notice='%s is perpetual (will not expire)' % license)
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
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:
if section[license].daysuntilexpire < crit:
state = State.CRIT
......@@ -206,10 +208,12 @@ def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicens
else:
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))
register.snmp_section(
name='cisco_asyncos_license',
parse_function=parse_cisco_asyncos_license,
......
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Rewriten by: Th.L.
# Date: 19-02-2020
# License: GNU General Public License v2
#
# 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
# 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-
# 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.
# 2020-05-14: added wato oprion to ignore items
# 2021-03-25: rewrite for CMK2.0
#
#
# sample snmpwalk
......@@ -144,116 +137,176 @@
# ASYNCOS-MAIL-MIB::updateFailures.14 = Counter32: 0
# ASYNCOS-MAIL-MIB::updateFailures.15 = Counter32: 0
#
# sample info
#
# [[u'File Reputation', u'1', u'0'],
# [u'IronPort Anti-Spam', u'10', u'0'],
# [u'McAfee', u'1', u'0'],
# [u'Sophos Anti-Virus', u'1', u'0'],
# [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']
# ]
#
from typing import Mapping, List, NamedTuple
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
factory_settings['cisco_asyncos_update_default_levels'] = {
'failedLevel': (5, 10),
'features_ignore': []
}
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
check_levels,
Result,
SNMPTree,
contains,
State,
render,
)
def inventory_cisco_asyncos_update(info):
if len(info) > 0:
return [(None, None)]
class CiscoAsyncosUpdate(NamedTuple):
updates: int
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:
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)
# {
# 'File Reputation': CiscoAsyncosUpdate(updates=6, updatefailures=38),
# 'IronPort Anti-Spam': CiscoAsyncosUpdate(updates=12, updatefailures=9),
# 'McAfee': CiscoAsyncosUpdate(updates=6, updatefailures=25),
# 'Sophos Anti-Virus': CiscoAsyncosUpdate(updates=6, updatefailures=17),
# 'amp': CiscoAsyncosUpdate(updates=1, updatefailures=0),
# 'content_scanner': CiscoAsyncosUpdate(updates=1, updatefailures=0),
# 'enrollment_client': CiscoAsyncosUpdate(updates=1, updatefailures=0),
# 'geo_countries': CiscoAsyncosUpdate(updates=1, updatefailures=0),
# 'howto': CiscoAsyncosUpdate(updates=0, updatefailures=0),
# 'openssh_key': CiscoAsyncosUpdate(updates=0, updatefailures=0),
# 'repeng': CiscoAsyncosUpdate(updates=0, updatefailures=0),
# 'sdr_client': CiscoAsyncosUpdate(updates=0, updatefailures=0),
# 'smart_agent': CiscoAsyncosUpdate(updates=0, updatefailures=0),
# 'support_request': CiscoAsyncosUpdate(updates=1, updatefailures=0),
# 'timezones': CiscoAsyncosUpdate(updates=1, updatefailures=0)
# }
def discovery_cisco_asyncos_update(section:Mapping[str, CiscoAsyncosUpdate])-> DiscoveryResult:
yield Service()
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
def check_cisco_asyncos_update(params, section:Mapping[str, CiscoAsyncosUpdate]) -> CheckResult:
features_ignore = params.get('features_ignore', [])
warn, crit = params.get('failedLevel')
ignore_count = 0
for feature in section.keys():
if feature in features_ignore:
yield Result(state=State.OK, notice='Feature %s: %d/%d updates/update failures. Feature ignored!' % (feature, section[feature].updates, section[feature].updatefailures))
ignore_count += 1
else:
yield Result(state=State.OK, notice='Feature %s: %d/%d updates/update failures. Feature ignored!' % (feature, section[feature].updates, section[feature].updatefailures))
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
yield Result(state=State.OK, summary='%d/%d Features found/ignored' % (len(section.keys()), ignore_count))
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'] = {
'check_function': check_cisco_asyncos_update,
'inventory_function': inventory_cisco_asyncos_update,
'group': 'cisco_asyncos_update',
'service_description': 'Update',
'has_perfdata': True,
'snmp_info': ('.1.3.6.1.4.1.15497.1.1.1.13.1', [ # ASYNCOS-MAIL-MIB::updateEntry
'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'],
}
register.check_plugin(
name='cisco_asyncos_update',
service_name='Update',
discovery_function=discovery_cisco_asyncos_update,
check_function=check_cisco_asyncos_update,
check_default_parameters={'failedLevel': (5, 10)},
check_ruleset_name='cisco_asyncos_update',
)
No preview for this file type
......@@ -37,8 +37,8 @@
'cisco_asyncos_messageage.py',
'cisco_asyncos_queue.py',
'cisco_asyncos_resources.py',
'cisco_asyncos_license.py'],
'checks': ['cisco_asyncos_update'],
'cisco_asyncos_license.py',
'cisco_asyncos_update.py'],
'web': ['plugins/wato/cisco_asyncos_license.py',
'plugins/wato/cisco_asyncos_queue.py',
'plugins/wato/cisco_asyncos_update.py',
......
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#
register_check_parameters(
subgroup_applications,
'cisco_asyncos_queue',
_('Cisco AsyncOS queue'),
Dictionary(
# help=_(''),
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')),
])),
],
),
None,
match_type='dict',
from cmk.gui.i18n import _
from cmk.gui.valuespec import (
Dictionary,
Integer,
TextAscii,
ListOfStrings,
Tuple,
)
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
# -*- encoding: utf-8; py-indent-offset: 4 -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#
register_check_parameters(
subgroup_applications,
'cisco_asyncos_update',
_('Cisco AsyncOS update'),
Dictionary(
# help=_(''),
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')),
])),
],
),
None,
match_type='dict',
from cmk.gui.i18n import _
from cmk.gui.valuespec import (
Dictionary,
Integer,
TextAscii,
ListOfStrings,
Tuple,
)
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