Created
August 27, 2017 20:15
-
-
Save cjsewell/a44d4ab9e2b5bc60244c78c4e010d3bf to your computer and use it in GitHub Desktop.
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 | |
HIGH=0.2; | |
LOG_FILE=/var/log/highload.log; | |
CURRENT_LOAD=$( uptime | awk -F'load average:' '{ print $2 }' | awk -F',' '{gsub(/[ \t]+/, "", $1); print $1}' ); | |
IS_HIGH=$( echo "$CURRENT_LOAD >= $HIGH" | bc ); | |
if [ $IS_HIGH -eq 1 ] ; then | |
top -b -n 1 2>&1 | while read line; do echo -e `/bin/date` "$line"; done >> $LOG_FILE | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment