move context above result

This commit is contained in:
2025-02-07 17:08:44 +01:00
parent ac9e80bf2b
commit 7be320c88b

View File

@@ -108,13 +108,6 @@ class SNMPSynologySystemResource(nagiosplugin.Resource):
return nagiosplugin.Metric(name='status', value=result, context='system_context')
class SNMPSynologySystemResult(nagiosplugin.Result):
def __str__(self):
if self.metric.value['status'] == '1': status = 'normal'
else: status = 'failed'
return f'{self.metric.value["model"]} (SN: {self.metric.value["sn"]}) is in status {status}!'
class SNMPSynologySystemContext(nagiosplugin.Context):
def __init__(self, name):
super().__init__(name, fmt_metric='{name} is', result_cls=SNMPSynologySystemResult)
@@ -127,6 +120,13 @@ class SNMPSynologySystemContext(nagiosplugin.Context):
return self.result_cls(nagiosplugin.Unknown, "unknown", metric)
class SNMPSynologySystemResult(nagiosplugin.Result):
def __str__(self):
if self.metric.value['status'] == '1': status = 'normal'
else: status = 'failed'
return f'{self.metric.value["model"]} (SN: {self.metric.value["sn"]}) is in status {status}!'
#
# Synology [DSM & DSM UC] Temperature of NAS
#
@@ -167,13 +167,6 @@ class SNMPSynologyPowerSupplyResource(nagiosplugin.Resource):
return nagiosplugin.Metric(name='status', value=result, context='powersupply_context')
class SNMPSynologyPowerSupplyResult(nagiosplugin.Result):
def __str__(self):
if self.metric.value == '1': status = 'normal'
else: status = 'failed'
return f'Power Supply is in status {status}!'
class SNMPSynologyPowerSupplyContext(nagiosplugin.Context):
def __init__(self, name):
super().__init__(name, fmt_metric='{name} is', result_cls=SNMPSynologyPowerSupplyResult)
@@ -186,6 +179,13 @@ class SNMPSynologyPowerSupplyContext(nagiosplugin.Context):
return self.result_cls(nagiosplugin.Unknown, "unknown", metric)
class SNMPSynologyPowerSupplyResult(nagiosplugin.Result):
def __str__(self):
if self.metric.value == '1': status = 'normal'
else: status = 'failed'
return f'Power Supply is in status {status}!'
#
# Synology [DSM & DSM UC] Returns error if system fan fails
#
@@ -209,13 +209,6 @@ class SNMPSynologyFansResource(nagiosplugin.Resource):
yield nagiosplugin.Metric(name=fan, value=result, context='fan_context')
class SNMPSynologyFansResult(nagiosplugin.Result):
def __str__(self):
if self.metric.value == '1': status = 'normal'
else: status = 'failed'
return f'{self.metric.name} fan is in status {status}!'
class SNMPSynologyFansContext(nagiosplugin.Context):
def __init__(self, name):
super().__init__(name, fmt_metric='{name} is', result_cls=SNMPSynologyFansResult)
@@ -228,6 +221,13 @@ class SNMPSynologyFansContext(nagiosplugin.Context):
return self.result_cls(nagiosplugin.Unknown, "unknown", metric)
class SNMPSynologyFansResult(nagiosplugin.Result):
def __str__(self):
if self.metric.value == '1': status = 'normal'
else: status = 'failed'
return f'{self.metric.name} fan is in status {status}!'
class SNMPSynologyFansSummary(nagiosplugin.Summary):
def verbose(self, results):
result_str = ''