diff --git a/agent_based/snmp_uptime.py b/agent_based/snmp_uptime.py index 111a697fcb39603161f98a2a0758a504df006c82..10c5a1f54b21d2c848afedf82a614389787659e6 100644 --- a/agent_based/snmp_uptime.py +++ b/agent_based/snmp_uptime.py @@ -4,7 +4,6 @@ # 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. -# 2022-03-06: extended to use snmpEngineTime if available # 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 # incremented as if a re-initialization had occurred, and this object's value consequently @@ -12,6 +11,10 @@ # 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 # +# 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 @@ -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 -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) - >>> 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) - >>> None is parse_snmp_uptime([[u'', u'Fortigate 80C', 'Whatever']]) # nonsense + >>> None is parse_snmp_uptime_extended([[u'', u'Fortigate 80C', 'Whatever']]) # nonsense True - >>> parse_snmp_uptime([['2297331594', '', '313671']]) + >>> parse_snmp_uptime_extended([['2297331594', '', '313671']]) Section(uptime_sec=313671, message=None) """ @@ -67,9 +70,10 @@ def parse_snmp_uptime(string_table: StringTable) -> Optional[uptime.Section]: register.snmp_section( - name="snmp_uptime", + name="snmp_uptime_extended", parsed_section_name="uptime", - parse_function=parse_snmp_uptime, + parse_function=parse_snmp_uptime_extended, + supersedes=['snmp_uptime'], fetch=SNMPTree( base=".1.3.6.1", oids=[ diff --git a/snmp_uptime.mkp b/snmp_uptime.mkp index 4070253ad883f660bc8e432f1fdb528b4aef1ecb..4dd7410995c1bfdea7f0628ea401095e824384b1 100644 Binary files a/snmp_uptime.mkp and b/snmp_uptime.mkp differ