From 40a9ac4523c22bad7007bbfead4bd1d5b0deec18 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Fri, 7 Jan 2022 18:07:33 +0100 Subject: [PATCH] bundles/sshmon: add check if OOM killer was active --- bundles/sshmon/files/check_oom_killer | 14 ++++++++++++++ bundles/sshmon/items.py | 1 + bundles/sshmon/metadata.py | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 bundles/sshmon/files/check_oom_killer diff --git a/bundles/sshmon/files/check_oom_killer b/bundles/sshmon/files/check_oom_killer new file mode 100644 index 0000000..d55e469 --- /dev/null +++ b/bundles/sshmon/files/check_oom_killer @@ -0,0 +1,14 @@ +#!/bin/bash + +journal="$(journalctl --since '12 hours ago' --no-hostname _TRANSPORT=kernel | grep -iF 'out of memory' -C1)" + +if [[ -n "$journal" ]] +then + echo "CRITICAL - OOM killer killed processes:" + echo + echo "$journal" + exit 2 +else + echo "OK - No OOM kills found in last 12 hours" + exit 0 +fi diff --git a/bundles/sshmon/items.py b/bundles/sshmon/items.py index 594cf66..1361eb2 100644 --- a/bundles/sshmon/items.py +++ b/bundles/sshmon/items.py @@ -55,6 +55,7 @@ for check in { 'http_wget', 'https_certificate_at_url', 'mounts', + 'oom_killer', 'pypi_for_new_release', 'ram', 'systemd_unit', diff --git a/bundles/sshmon/metadata.py b/bundles/sshmon/metadata.py index aa7ba3b..4fc3df2 100644 --- a/bundles/sshmon/metadata.py +++ b/bundles/sshmon/metadata.py @@ -19,7 +19,10 @@ defaults = { }, 'LOAD': { 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_load -r -w 4,2,1 -c 8,4,2', - } + }, + 'OOM KILLER': { + 'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_oom_killer', + }, }, }, },