cat << 'EOL' >/usr/local/bin/load_checker.sh
#!/bin/bash
# Original Script found here
# https://www.christophe-casalegno.com/2015/07/14/how-to-automatically-take-an-action-if-the-load-average-is-too-high/
# Modified by FreSoftwareServers
#

# Variables
llimit=2
alert=fresoftwareservers@gmail.com

# Currnet System
host=`hostname -f`
date=`date`

# Current Load
load=`cat /proc/loadavg | awk {'print $1'} | cut -d "." -f1`

echo "$llimit"

if test "$load" -ge "$llimit"

then


# Take Immediate Action
reboot

# Send E-mail Alert and insert into loadavg.log
echo "The Load Average has reached $load on $host" | mail -s "$host : High Load Average Alert" "$alert"
echo "$date : The Load Average has reached $load1 and $load2 on $host" >> /var/log/loadavg.log

echo "ok" 1>&2

fi
EOL
chmod +x /usr/local/bin/load_checker.sh
/usr/local/bin/load_checker.sh
cat << 'EOL' >/etc/cron.d/load_checker
*/15 * * * * root /usr/local/bin/load_checker.sh
EOL
chmod +x /etc/cron.d/load_checker