Icinga2/Nagios check for Out of memory problems. ATM it check all dmesg output. If you want after check make it green again, you need to run dmesg -c.
The original version of this check assumes that non-root users can run /bin/dmesg, which is true on Ubuntu but not Debian (and likely other distros). While you can give unprivileged users access to /bin/dmesg with sudo sysctl -w kernel.dmesg_restrict=1 (source), this has security implications. Instead, I've created a variant that uses a setuid wrapper, hard-coding the path to the original Nagios check to prohibit setuid abuse.
- Place
check_oom.pyandcheck_oom_wrapperin/usr/lib/nagios/plugins. - If you have a different file path for your plugins, you will need to recompile
check_oom_wrapper.cafter modifying theREAL_PATHdefinition on line 3. Usegcc -o check_oom_wrapper check_oom_wrapper.c - Set the setuid flag on the wrapper file:
sudo chmod u+s /usr/lib/nagios/plugins/check_oom_wrapperAs a future improvement, it would be nice to detect whether the script is running as root, and only call setuid() on the Python subprocess if necessary.
usage: check_oom.py [-h] [-m {warning,critical,default}] [-v]
Check for OOM killer events
optional arguments:
-h, --help show this help message and exit
-m {warning,critical,default}, --mode {warning,critical,default}
Mode of results for this check: warning, critical,
default
-s, --short If this option is specified, check ignores dmesg OOM
problems older then 24 hours
-v, --verbose Show verbose output from demsg about OOM killer events
check_oom.py: v.1.1 by Dmytro Prokhorenkov