add memory check
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
- https://easysnmp.readthedocs.io/en/latest/session_api.html
|
||||
"""
|
||||
|
||||
__version__ = '0.6.0'
|
||||
__version__ = '0.7.0'
|
||||
__author__ = 'anima'
|
||||
|
||||
# imports
|
||||
@@ -300,7 +300,7 @@ class SNMPSynologyCPUResource(nagiosplugin.Resource):
|
||||
self.session = session
|
||||
|
||||
def probe(self) -> list:
|
||||
"""check system temperature in °C
|
||||
"""check cpu usage %
|
||||
|
||||
Returns:
|
||||
nagiosplugin.Metric: single metric element (return)
|
||||
@@ -314,6 +314,28 @@ class SNMPSynologyCPUResource(nagiosplugin.Resource):
|
||||
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
|
||||
@@ -341,6 +363,7 @@ def parse_args() -> argparse.Namespace:
|
||||
'fans',
|
||||
'firmware',
|
||||
'cpu',
|
||||
'memory',
|
||||
],
|
||||
help='check mode to run')
|
||||
|
||||
@@ -416,6 +439,11 @@ def main():
|
||||
nagiosplugin.ScalarContext(name='cpu_scalar_context', warning=args.warning, critical=args.critical),
|
||||
nagiosplugin.Summary())
|
||||
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 _:
|
||||
raise nagiosplugin.CheckError(f'Unknown check mode: {args.check_mode}')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user