Created
April 16, 2016 15:10
-
-
Save bmhatfield/0906029f06bcdca97f20844761d80b0a to your computer and use it in GitHub Desktop.
A simple, time-based OOM check script for use with riemann-sumd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run on a minutely basis by https://github.com/bmhatfield/riemann-sumd/ | |
LAST_OOM_WINDOW=5; | |
LAST_OOM="$(grep 'Out of memory' /var/log/kern.log | tail -n 1)"; | |
LAST_OOM_TIME=${LAST_OOM:0:15}; | |
if [ -n "${LAST_OOM_TIME}" ]; then | |
if [ $(($((`date +%s` - `date --date="${LAST_OOM_TIME}" +%s`)) / 60 )) -le ${LAST_OOM_WINDOW} ]; then | |
echo "CRITICAL: OOM within last ${LAST_OOM_WINDOW} minutes!" | |
echo ${LAST_OOM} | |
exit 2 | |
else | |
echo "OK: Recent OOM but outside last ${LAST_OOM_WINDOW} minutes"; | |
echo "LAST_OOM: ${LAST_OOM}" | |
exit 0 | |
fi; | |
else | |
echo "OK: No recent OOM"; | |
exit 0 | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment