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 cb062fb6 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent 559f8c70
Branches 2.0.x
No related tags found
No related merge requests found
......@@ -9,13 +9,13 @@
from typing import Mapping, Dict, List, Tuple, NamedTuple
from .agent_based_api.v1.type_defs import (
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
from .agent_based_api.v1 import (
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
check_levels,
......
......@@ -43,13 +43,13 @@
from typing import Dict, List
from .agent_based_api.v1.type_defs import (
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
from .agent_based_api.v1 import (
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
check_levels,
......
......@@ -156,7 +156,7 @@ class CiscoAsyncosLicense(NamedTuple):
# ['Outbreak Filters', '2', '32542740'],
# ['Sophos Anti-Virus', '2', '32542740']
# ]]
def parse_cisco_asyncos_license(string_table: List[StringTable]) -> Mapping[str, CiscoAsyncosLicense]:
def parse_cisco_asyncos_feature_keys(string_table: List[StringTable]) -> Mapping[str, CiscoAsyncosLicense]:
licenses = {}
for license, isperpetual, secondsuntilexpire in string_table[0]:
licenses.update({license: CiscoAsyncosLicense(
......@@ -182,12 +182,12 @@ def parse_cisco_asyncos_license(string_table: List[StringTable]) -> Mapping[str,
# 'Sophos Anti-Virus': CiscoAsyncosLicense(perpetual=False, secondsuntilexpire=32542740, daysuntilexpire=376, expiredate='06 Apr 2022')
# }
def discovery_cisco_asyncos_license(section: Mapping[str, CiscoAsyncosLicense]) -> DiscoveryResult:
def discovery_cisco_asyncos_feature_keys(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:
def check_cisco_asyncos_feature_keys(params, section: Mapping[str, CiscoAsyncosLicense]) -> CheckResult:
features_ignore = params.get('features_ignore', [])
warn, crit = params.get('expire')
ignore_count = 0
......@@ -215,8 +215,8 @@ def check_cisco_asyncos_license(params, section: Mapping[str, CiscoAsyncosLicens
register.snmp_section(
name='cisco_asyncos_license',
parse_function=parse_cisco_asyncos_license,
name='cisco_asyncos_feature_keys',
parse_function=parse_cisco_asyncos_feature_keys,
fetch=[
SNMPTree(
base='.1.3.6.1.4.1.15497.1.1.1.12.1', # ASYNCOS-MAIL-MIB::keyExpirationEntry
......@@ -231,10 +231,10 @@ register.snmp_section(
)
register.check_plugin(
name='cisco_asyncos_license',
service_name='License',
discovery_function=discovery_cisco_asyncos_license,
check_function=check_cisco_asyncos_license,
name='cisco_asyncos_feature_keys',
service_name='Feature keys',
discovery_function=discovery_cisco_asyncos_feature_keys,
check_function=check_cisco_asyncos_feature_keys,
check_default_parameters={'expire': (30, 7)},
check_ruleset_name='cisco_asyncos_license',
check_ruleset_name='cisco_asyncos_feature_keys',
)
......@@ -34,13 +34,13 @@
from typing import Dict, List, NamedTuple
from .agent_based_api.v1.type_defs import (
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
from .agent_based_api.v1 import (
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
Result,
......
......@@ -24,13 +24,13 @@
from typing import Mapping, Dict, List, Tuple, NamedTuple
from .agent_based_api.v1.type_defs import (
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
from .agent_based_api.v1 import (
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
check_levels,
......@@ -38,7 +38,7 @@ from .agent_based_api.v1 import (
contains,
)
from .utils.temperature import (
from cmk.base.plugins.agent_based.utils.temperature import (
check_temperature,
TempParamType,
)
......
......@@ -7,7 +7,7 @@
# URL : https://thl-cmk.hopto.org
# Date : 2020-02-19
#
# 2020-05-14: added wato oprion to ignore items
# 2020-05-14: added wato option to ignore items
# 2021-03-25: rewrite for CMK2.0
#
#
......@@ -148,14 +148,17 @@ from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
check_levels,
Result,
SNMPTree,
contains,
State,
render,
Metric,
)
from cmk.base.item_state import (
get_item_state,
set_item_state,
)
class CiscoAsyncosUpdate(NamedTuple):
updates: int
......@@ -178,7 +181,7 @@ class CiscoAsyncosUpdate(NamedTuple):
# ['support_request', '1', '0'],
# ['timezones', '1', '0']
# ]]
def parse_cisco_asyncos_update(string_table: List[StringTable]) -> Mapping[str, CiscoAsyncosUpdate]:
def parse_cisco_asyncos_updates(string_table: List[StringTable]) -> Mapping[str, CiscoAsyncosUpdate]:
features = {}
for feature, updates, update_failures in string_table[0]:
features.update({feature: CiscoAsyncosUpdate(
......@@ -204,90 +207,76 @@ def parse_cisco_asyncos_update(string_table: List[StringTable]) -> Mapping[str,
# 'support_request': CiscoAsyncosUpdate(updates=1, updatefailures=0),
# 'timezones': CiscoAsyncosUpdate(updates=1, updatefailures=0)
# }
def discovery_cisco_asyncos_update(section:Mapping[str, CiscoAsyncosUpdate])-> DiscoveryResult:
def discovery_cisco_asyncos_updates(section:Mapping[str, CiscoAsyncosUpdate])-> DiscoveryResult:
yield Service()
def check_cisco_asyncos_update(params, section:Mapping[str, CiscoAsyncosUpdate]) -> CheckResult:
def check_cisco_asyncos_updates(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
failed = section[feature].updatefailures
passed = section[feature].updates
# read counters
passedLast = get_item_state('cisco_asyncos_updates_%s_passedLast' % feature)
failedLast = get_item_state('cisco_asyncos_updates_%s_failedLast' % feature)
failedAttempts = get_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature)
# print('Feature %s, passed: %s/%s failed: %s/%s, Attempts: %s' % (feature, passed,passedLast, failed,failedLast, failedAttempts))
if (passedLast == None) or (failedLast == None) or (failedAttempts == None): # or (lastState == None):
# init counters
set_item_state('cisco_asyncos_updates_%s_passedLast' % feature, passed)
set_item_state('cisco_asyncos_updates_%s_failedLast' % feature, failed)
set_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature, 0)
else:
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_updates_%s_passedLast' % feature, passed)
set_item_state('cisco_asyncos_updates_%s_failedLast' % feature, failed)
passedLast = int(passedLast)
failedLast = int(failedLast)
failedAttempts = int(failedAttempts)
yield Result(state=State.OK, summary='%d/%d Features found/ignored' % (len(section.keys()), ignore_count))
# reset counter if overrun
if failed < failedLast:
set_item_state('cisco_asyncos_updates_%s_failedLast' % feature, failed)
failedLast = failed
if passed < passedLast:
set_item_state('cisco_asyncos_updates_%s_passedLast' % feature, passed)
passedLast = passed
if passed > passedLast:
# reset error counter after passed update attempt
set_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature, 0)
else:
failedAttempts = failedAttempts + failed - failedLast
set_item_state('cisco_asyncos_updates_%s_failedAttempts' % feature, failedAttempts)
if feature in features_ignore:
yield Result(state=State.OK, notice='%s: %d/%d updates/update failures. Feature ignored!' % (feature, passed, failed))
ignore_count += 1
else:
if failedAttempts >= crit:
yield Result(state=State.CRIT, notice='%s: %d/%d passed/failed.' % (feature, passed, failed))
lastState=-1
elif failedAttempts >= warn:
yield Result(state=State.WARN, notice='%s: %d/%d passed/failed.' % (feature, passed, failed))
lastState=-1
else:
yield Result(state=State.OK, notice='%s: %d/%d passed/failed.' % (feature, passed, failed))
lastState=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
yield Metric(
name=feature.replace(' ', '_'),
value=lastState,
boundaries=(2,-2)
)
yield Result(state=State.OK, summary='%d/%d Features found/ignored' % (len(section.keys()), ignore_count))
register.snmp_section(
name='cisco_asyncos_update',
parse_function=parse_cisco_asyncos_update,
name='cisco_asyncos_updates',
parse_function=parse_cisco_asyncos_updates,
fetch=[
SNMPTree(
base='.1.3.6.1.4.1.15497.1.1.1.13.1', # ASYNCOS-MAIL-MIB::updateEntry
......@@ -302,11 +291,11 @@ register.snmp_section(
)
register.check_plugin(
name='cisco_asyncos_update',
service_name='Update',
discovery_function=discovery_cisco_asyncos_update,
check_function=check_cisco_asyncos_update,
name='cisco_asyncos_updates',
service_name='Updates',
discovery_function=discovery_cisco_asyncos_updates,
check_function=check_cisco_asyncos_updates,
check_default_parameters={'failedLevel': (5, 10)},
check_ruleset_name='cisco_asyncos_update',
check_ruleset_name='cisco_asyncos_updates',
)
No preview for this file type
......@@ -37,12 +37,12 @@
'cisco_asyncos_messageage.py',
'cisco_asyncos_queue.py',
'cisco_asyncos_resources.py',
'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',
'plugins/metrics/cisco_asyncos.py']},
'cisco_asyncos_feature_keys.py',
'cisco_asyncos_updates.py'],
'web': ['plugins/wato/cisco_asyncos_queue.py',
'plugins/metrics/cisco_asyncos.py',
'plugins/wato/cisco_asyncos_feature_keys.py',
'plugins/wato/cisco_asyncos_updates.py']},
'name': 'cisco_asyncos',
'num_files': 19,
'title': 'Cisco AsyncOS (IronPort) checks',
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#
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_feature_keys():
return Dictionary(elements=[
('features_ignore',
ListOfStrings(
title=_('feature keys features to ignore'),
orientation='vertical',
allow_empty=False,
help=_('there will be no warning/critical if this features are expired'
'Examples: McAfee, IronPort Email Encryption, Data Loss Prevention, etc.'),
)
),
('expire',
Tuple(
title=_('Levels for feature key expiration in days'),
elements=[
Integer(title=_('Warning'), default_value=30, unit=_('days before expiration')),
Integer(title=_('Critical'), default_value=7, unit=_('days before expiration')),
])),
])
rulespec_registry.register(
CheckParameterRulespecWithItem(
check_group_name='cisco_asyncos_feature_keys',
group=RulespecGroupCheckParametersNetworking,
item_spec=lambda: TextAscii(title=_('Cisco AsyncOS feature keys'), ),
match_type='dict',
parameter_valuespec=_parameter_valuespec_cisco_asyncos_feature_keys,
title=lambda: _('Cisco AsyncOS feature keys'),
))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
#
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_updates():
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_updates',
group=RulespecGroupCheckParametersNetworking,
item_spec=lambda: TextAscii(title=_('Cisco AsyncOS updates'), ),
match_type='dict',
parameter_valuespec=_parameter_valuespec_cisco_asyncos_updates,
title=lambda: _('Cisco AsyncOS updates'),
))
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