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

update project

parent 0157b441
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and # This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package. # conditions defined in the file COPYING, which is part of this source code package.
# 2022-03-06: extended to use snmpEngineTime if available
# snmpEngineTime : The number of seconds since the value of the snmpEngineBoots object last changed. When # snmpEngineTime : The number of seconds since the value of the snmpEngineBoots object last changed. When
# incrementing this object's value would cause it to exceed its maximum, snmpEngineBoots is # incrementing this object's value would cause it to exceed its maximum, snmpEngineBoots is
# incremented as if a re-initialization had occurred, and this object's value consequently # incremented as if a re-initialization had occurred, and this object's value consequently
...@@ -12,6 +11,10 @@ ...@@ -12,6 +11,10 @@
# snmpEngineBoots: The number of times that the SNMP engine has (re-)initialized itself since snmpEngineID was # snmpEngineBoots: The number of times that the SNMP engine has (re-)initialized itself since snmpEngineID was
# last configured. On Cisco Device this gives the number of reboots # last configured. On Cisco Device this gives the number of reboots
# #
# 2022-03-06: extended to use snmpEngineTime if available
# 2022-03-07: fixed if snmpEngineTime == 0
# 2022-03-08: renamed to snmp_uptime_extended to avoid caching issues with the original check
#
from typing import Optional from typing import Optional
...@@ -20,15 +23,15 @@ from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import StringTabl ...@@ -20,15 +23,15 @@ from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import StringTabl
from cmk.base.plugins.agent_based.utils import uptime from cmk.base.plugins.agent_based.utils import uptime
def parse_snmp_uptime(string_table: StringTable) -> Optional[uptime.Section]: def parse_snmp_uptime_extended(string_table: StringTable) -> Optional[uptime.Section]:
""" """
>>> parse_snmp_uptime([['2297331594', '', '']]) >>> parse_snmp_uptime_extended([['2297331594', '', '']])
Section(uptime_sec=22973315, message=None) Section(uptime_sec=22973315, message=None)
>>> parse_snmp_uptime([['124:21:26:42.03', '124:21:29:01.14', '']]) >>> parse_snmp_uptime_extended([['124:21:26:42.03', '124:21:29:01.14', '']])
Section(uptime_sec=10790941, message=None) Section(uptime_sec=10790941, message=None)
>>> None is parse_snmp_uptime([[u'', u'Fortigate 80C', 'Whatever']]) # nonsense >>> None is parse_snmp_uptime_extended([[u'', u'Fortigate 80C', 'Whatever']]) # nonsense
True True
>>> parse_snmp_uptime([['2297331594', '', '313671']]) >>> parse_snmp_uptime_extended([['2297331594', '', '313671']])
Section(uptime_sec=313671, message=None) Section(uptime_sec=313671, message=None)
""" """
...@@ -67,9 +70,10 @@ def parse_snmp_uptime(string_table: StringTable) -> Optional[uptime.Section]: ...@@ -67,9 +70,10 @@ def parse_snmp_uptime(string_table: StringTable) -> Optional[uptime.Section]:
register.snmp_section( register.snmp_section(
name="snmp_uptime", name="snmp_uptime_extended",
parsed_section_name="uptime", parsed_section_name="uptime",
parse_function=parse_snmp_uptime, parse_function=parse_snmp_uptime_extended,
supersedes=['snmp_uptime'],
fetch=SNMPTree( fetch=SNMPTree(
base=".1.3.6.1", base=".1.3.6.1",
oids=[ oids=[
......
No preview for this file type
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