Skip to content

Instantly share code, notes, and snippets.

@typhonius
Created August 8, 2014 07:49
Show Gist options
  • Save typhonius/2fd53fc1951b74f5491e to your computer and use it in GitHub Desktop.
Save typhonius/2fd53fc1951b74f5491e to your computer and use it in GitHub Desktop.
Ultra dirty, super basic, nagios replacement.
#!/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