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

update project

parent 00c9629e
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/snmp_uptime-0.0.2-20230805.mkp "snmp_uptime-0.0.2-20230805.mkp"
# SNMP uptime
This check is based on the snmp_uptime check form CMK. It adds the SNMP-FRAMEWORK-MIB::snmpEngineTime OID to the check. Its value is in seconds not ticks and therefore the Uptime can now be around 68 years before a rollover of the counter :-)
......
......@@ -14,7 +14,7 @@
# 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
#
# 2023-08-05: made parse function more stable (try/except/else)
from typing import Optional
......@@ -35,22 +35,23 @@ def parse_snmp_uptime_extended(string_table: StringTable) -> Optional[uptime.Sec
Section(uptime_sec=313671, message=None)
"""
if not string_table:
return None
sysUpTime, hrSystemUptime, snmpEngineTime = string_table[0]
try:
sysUpTime, hrSystemUptime, snmpEngineTime = string_table[0]
except ValueError:
return
ticks = sysUpTime or hrSystemUptime
if len(ticks) < 3:
return None
return
try:
value = int(snmpEngineTime)
if value > 0:
return uptime.Section(int(snmpEngineTime), None)
except ValueError:
pass
else:
if value > 0:
return uptime.Section(int(snmpEngineTime), None)
try:
return uptime.Section(int(ticks[:-2]), None)
......@@ -59,14 +60,13 @@ def parse_snmp_uptime_extended(string_table: StringTable) -> Optional[uptime.Sec
try:
days, h, m, s = ticks.split(":")
except ValueError:
pass
else:
return uptime.Section(
(int(days) * 86400) + (int(h) * 3600) + (int(m) * 60) + int(float(s)),
None,
)
except ValueError:
pass
return None
register.snmp_section(
......
......@@ -7,9 +7,8 @@
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['snmp_uptime.py']},
'name': 'snmp_uptime',
'num_files': 1,
'title': 'SNMP Uptime',
'version': '20220306.v0.0.1',
'version.min_required': '2021.09.20',
'version.packaged': '2021.09.20',
'version.usable_until': None}
\ No newline at end of file
'version': '0.0.2-20230805',
'version.min_required': '2.0.0b1',
'version.packaged': '2.2.0p7',
'version.usable_until': None}
File added
File deleted
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