move context above result
This commit is contained in:
@@ -108,13 +108,6 @@ class SNMPSynologySystemResource(nagiosplugin.Resource):
|
|||||||
return nagiosplugin.Metric(name='status', value=result, context='system_context')
|
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):
|
class SNMPSynologySystemContext(nagiosplugin.Context):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
super().__init__(name, fmt_metric='{name} is', result_cls=SNMPSynologySystemResult)
|
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)
|
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
|
# 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')
|
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):
|
class SNMPSynologyPowerSupplyContext(nagiosplugin.Context):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
super().__init__(name, fmt_metric='{name} is', result_cls=SNMPSynologyPowerSupplyResult)
|
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)
|
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
|
# 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')
|
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):
|
class SNMPSynologyFansContext(nagiosplugin.Context):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
super().__init__(name, fmt_metric='{name} is', result_cls=SNMPSynologyFansResult)
|
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)
|
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):
|
class SNMPSynologyFansSummary(nagiosplugin.Summary):
|
||||||
def verbose(self, results):
|
def verbose(self, results):
|
||||||
result_str = ''
|
result_str = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user