add memory check
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
- https://easysnmp.readthedocs.io/en/latest/session_api.html
|
- https://easysnmp.readthedocs.io/en/latest/session_api.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '0.6.0'
|
__version__ = '0.7.0'
|
||||||
__author__ = 'anima'
|
__author__ = 'anima'
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
@@ -300,7 +300,7 @@ class SNMPSynologyCPUResource(nagiosplugin.Resource):
|
|||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
def probe(self) -> list:
|
def probe(self) -> list:
|
||||||
"""check system temperature in °C
|
"""check cpu usage %
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
nagiosplugin.Metric: single metric element (return)
|
nagiosplugin.Metric: single metric element (return)
|
||||||
@@ -314,6 +314,28 @@ class SNMPSynologyCPUResource(nagiosplugin.Resource):
|
|||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Synology [DSM & DSM UC] Utilization % is the sum of user and system CPU usage
|
||||||
|
#
|
||||||
|
class SNMPSynologyMemoryResource(nagiosplugin.Resource):
|
||||||
|
def __init__(self, session) -> None:
|
||||||
|
self.session = session
|
||||||
|
|
||||||
|
def probe(self) -> list:
|
||||||
|
"""check memory usage in %
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
nagiosplugin.Metric: single metric element (return)
|
||||||
|
"""
|
||||||
|
baseoid = '.1.3.6.1.4.1.6574.1'
|
||||||
|
oids = dict()
|
||||||
|
result = self.session.get(baseoid + '.7.2.0').value
|
||||||
|
return nagiosplugin.Metric(name='memory', value=int(result), uom='%', context='memory_scalar_context')
|
||||||
|
|
||||||
|
def __init__(self, session) -> None:
|
||||||
|
self.session = session
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Arguments
|
# Arguments
|
||||||
@@ -341,6 +363,7 @@ def parse_args() -> argparse.Namespace:
|
|||||||
'fans',
|
'fans',
|
||||||
'firmware',
|
'firmware',
|
||||||
'cpu',
|
'cpu',
|
||||||
|
'memory',
|
||||||
],
|
],
|
||||||
help='check mode to run')
|
help='check mode to run')
|
||||||
|
|
||||||
@@ -416,6 +439,11 @@ def main():
|
|||||||
nagiosplugin.ScalarContext(name='cpu_scalar_context', warning=args.warning, critical=args.critical),
|
nagiosplugin.ScalarContext(name='cpu_scalar_context', warning=args.warning, critical=args.critical),
|
||||||
nagiosplugin.Summary())
|
nagiosplugin.Summary())
|
||||||
check.name = "CPU Usage"
|
check.name = "CPU Usage"
|
||||||
|
case 'memory':
|
||||||
|
check = nagiosplugin.Check(SNMPSynologyMemoryResource(session=session),
|
||||||
|
nagiosplugin.ScalarContext(name='memory_scalar_context', warning=args.warning, critical=args.critical),
|
||||||
|
nagiosplugin.Summary())
|
||||||
|
check.name = "Memory Usage"
|
||||||
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