add system temp check
This commit is contained in:
@@ -83,7 +83,7 @@ def init_snmp_session(hostname: str = 'localhost', snmp_version: str | int = '2'
|
|||||||
return session
|
return session
|
||||||
|
|
||||||
#
|
#
|
||||||
# Synology System Status
|
# Synology [DSM & DSM UC] System partition status.
|
||||||
#
|
#
|
||||||
class SNMPSynologySystemResource(nagiosplugin.Resource):
|
class SNMPSynologySystemResource(nagiosplugin.Resource):
|
||||||
def __init__(self, session) -> None:
|
def __init__(self, session) -> None:
|
||||||
@@ -127,6 +127,29 @@ class SNMPSynologySystemContext(nagiosplugin.Context):
|
|||||||
return self.result_cls(nagiosplugin.Unknown, "unknown", metric)
|
return self.result_cls(nagiosplugin.Unknown, "unknown", metric)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Synology [DSM & DSM UC] Temperature of NAS
|
||||||
|
#
|
||||||
|
class SNMPSynologySysTempResource(nagiosplugin.Resource):
|
||||||
|
def __init__(self, session) -> None:
|
||||||
|
self.session = session
|
||||||
|
|
||||||
|
def probe(self) -> list:
|
||||||
|
"""check system status (normal or failed).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
nagiosplugin.Metric: single metric element (return)
|
||||||
|
"""
|
||||||
|
baseoid = '.1.3.6.1.4.1.6574.1'
|
||||||
|
oids = dict()
|
||||||
|
result = self.session.get(baseoid + '.2.0').value
|
||||||
|
return nagiosplugin.Metric(name='systemp', value=int(result), context='systemp_scalar_context')
|
||||||
|
|
||||||
|
def __init__(self, session) -> None:
|
||||||
|
self.session = session
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Arguments
|
# Arguments
|
||||||
#
|
#
|
||||||
@@ -148,7 +171,7 @@ def parse_args() -> argparse.Namespace:
|
|||||||
argp.add_argument('-m', '--check_mode',
|
argp.add_argument('-m', '--check_mode',
|
||||||
choices=[
|
choices=[
|
||||||
'system',
|
'system',
|
||||||
'template2',
|
'systemp',
|
||||||
],
|
],
|
||||||
help='check mode to run')
|
help='check mode to run')
|
||||||
|
|
||||||
@@ -199,6 +222,11 @@ def main():
|
|||||||
SNMPSynologySystemContext(name='system_context'),
|
SNMPSynologySystemContext(name='system_context'),
|
||||||
nagiosplugin.Summary())
|
nagiosplugin.Summary())
|
||||||
check.name = "System Status"
|
check.name = "System Status"
|
||||||
|
case 'systemp':
|
||||||
|
check = nagiosplugin.Check(SNMPSynologySysTempResource(session=session),
|
||||||
|
nagiosplugin.ScalarContext(name='systemp_scalar_context', warning=args.warning, critical=args.critical),
|
||||||
|
nagiosplugin.Summary())
|
||||||
|
check.name = "System Temperatur"
|
||||||
case _:
|
case _:
|
||||||
raise nagiosplugin.CheckError(f'Unknown check mode: {args.check_mode}')
|
raise nagiosplugin.CheckError(f'Unknown check mode: {args.check_mode}')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user