From 135863cdf8d2d42a444172c1a3a13d29e14c8fd4 Mon Sep 17 00:00:00 2001
From: anima
Date: Fri, 7 Feb 2025 16:36:25 +0100
Subject: [PATCH] add system temp check
---
checks/check_snmp_synology.py | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/checks/check_snmp_synology.py b/checks/check_snmp_synology.py
index 059c661..bd6e552 100755
--- a/checks/check_snmp_synology.py
+++ b/checks/check_snmp_synology.py
@@ -83,7 +83,7 @@ def init_snmp_session(hostname: str = 'localhost', snmp_version: str | int = '2'
return session
#
-# Synology System Status
+# Synology [DSM & DSM UC] System partition status.
#
class SNMPSynologySystemResource(nagiosplugin.Resource):
def __init__(self, session) -> None:
@@ -127,6 +127,29 @@ class SNMPSynologySystemContext(nagiosplugin.Context):
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
#
@@ -148,7 +171,7 @@ def parse_args() -> argparse.Namespace:
argp.add_argument('-m', '--check_mode',
choices=[
'system',
- 'template2',
+ 'systemp',
],
help='check mode to run')
@@ -199,6 +222,11 @@ def main():
SNMPSynologySystemContext(name='system_context'),
nagiosplugin.Summary())
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 _:
raise nagiosplugin.CheckError(f'Unknown check mode: {args.check_mode}')