From 9310fde059e9adde9f28fee2a4528246005a2e56 Mon Sep 17 00:00:00 2001 From: KreativeKrise Date: Tue, 16 Feb 2021 11:48:55 +0100 Subject: [PATCH 1/3] Include cached memory into unused memory calculation The memory calculation should also count cached memory into unused memory, because cached memory will be freed when applications require it. --- check_synology.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/check_synology.py b/check_synology.py index 55c740d..cf00c53 100644 --- a/check_synology.py +++ b/check_synology.py @@ -76,7 +76,9 @@ def exitCode(): if mode == 'memory': memory_total = float(snmpget('1.3.6.1.4.1.2021.4.5.0')) - memory_unused = float(snmpget('1.3.6.1.4.1.2021.4.6.0')) + memory_avail = float(snmpget('1.3.6.1.4.1.2021.4.6.0')) + memory_cached = float(snmpget('1.3.6.1.4.1.2021.4.15.0')) + memory_unused = memory_avail + memory_cached memory_percent = 100 / memory_total * memory_unused if warning and warning > int(memory_percent): From d236bcbdd2fab2ded0c9c25e94a23a5a766f560e Mon Sep 17 00:00:00 2001 From: wernerfred <20406381+wernerfred@users.noreply.github.com> Date: Tue, 16 Feb 2021 15:38:00 +0100 Subject: [PATCH 2/3] feat: introducing usable memory --- check_synology.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check_synology.py b/check_synology.py index cf00c53..86d5786 100644 --- a/check_synology.py +++ b/check_synology.py @@ -76,17 +76,17 @@ def exitCode(): if mode == 'memory': memory_total = float(snmpget('1.3.6.1.4.1.2021.4.5.0')) - memory_avail = float(snmpget('1.3.6.1.4.1.2021.4.6.0')) + memory_unused = float(snmpget('1.3.6.1.4.1.2021.4.6.0')) memory_cached = float(snmpget('1.3.6.1.4.1.2021.4.15.0')) - memory_unused = memory_avail + memory_cached - memory_percent = 100 / memory_total * memory_unused + memory_usable = memory_unused + memory_cached + memory_percent = 100 / memory_total * memory_usable if warning and warning > int(memory_percent): state = 'WARNING' if critical and critical > int(memory_percent): state = 'CRITICAL' - print(state + ' - {:0.1f}% '.format(memory_percent) + 'free ({0:0.1f} MB out of {1:0.1f} MB)'.format((memory_unused / 1024), (memory_total / 1024)), '|memory_total=%dc' % memory_total, 'memory_unused=%dc' % memory_unused , 'memory_percent=%d' % memory_percent + '%') + print(state + ' - {:0.1f}% '.format(memory_percent) + 'usable ({0:0.1f} MB free and {1:0.1f} MB cached out of {2:0.1f} MB)'.format((memory_unused / 1024), (memory_cached / 1024), (memory_total / 1024)), '|memory_total=%dc' % memory_total, 'memory_unused=%dc' % memory_unused, 'memory_cached=%dc' % memory_cached, 'memory_usable=%dc' % memory_usable, 'memory_percent=%d' % memory_percent + '%') exitCode() if mode == 'disk': From cc81ffbb6f740329e3f2d05690447ed4d86313a9 Mon Sep 17 00:00:00 2001 From: wernerfred <20406381+wernerfred@users.noreply.github.com> Date: Tue, 16 Feb 2021 15:41:21 +0100 Subject: [PATCH 3/3] docs: correct memory terms --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e84ebf..d0c8a6e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Available modes: | mode | description | warning/critical | | :-----: | -------------------------------------------------------------------------- | ----------------------------------- | | load | Checks the load1, load5 and load15 values | if more than w/c in int (only load1)| -| memory | Checks the physical installed memory (free and total) | if less free than w/c in % | +| memory | Checks the physical installed memory (unused, cached and total) | if less usable than w/c in % | | disk | Detects and checks all disks (name, status, temperature) | if temp higher than w/c in °C
if c is set it will also trigger if status
is Failure or Crashed | | storage | Detects and checks all disks (free, total, %) | if more used than w/c in % | | update | Shows the current DSM version and if DSM update is available | set w/c to any int this triggers:
warning if available and critical
if other than un-/available |