Created
August 8, 2014 07:49
-
-
Save typhonius/2fd53fc1951b74f5491e to your computer and use it in GitHub Desktop.
Ultra dirty, super basic, nagios replacement.
This file contains hidden or 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 | |
STLOAD=$(cat /proc/loadavg | awk '{print $1}') | |
while true; do | |
FINLOAD=$(cat /proc/loadavg | awk '{print $1}') | |
if (( $(echo "$STLOAD $FINLOAD" | awk '{ if ($1 >= 8 && $2 >= 8) print 1}') )); then | |
if [[ -z $TIME ]]; then | |
TIME=$(date +"%s") | |
fi | |
ONGOING=$(($(date +"%s") - $TIME)) | |
echo "Ongoing for $ONGOING seconds." | mail -s"Sustained high load - [ $FINLOAD ]" [email protected] | |
else | |
TIME= | |
fi | |
STLOAD=$FINLOAD | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment