shell script to check cpu load on many servers

Pardon my noobness, what are the tools to prevent runaway processes eating 100% cpu and how to do that without running something constantly in the target server's memory?

Here is the shell script that if put into cron will preodically check servers via ssh

#!/bin/bash
#to crontab for checks every 15 mins
#0,15 * * * * /path/to/this/script
#must be run once to suppress ssh hello screen
#touch ~/.hushlogin
#put here your server's ips
declare -a ips=("10.0.0.1" "10.0.0.2" "10.0.0.3" "10.0.0.4" "10.0.0.5")

for i in "${ips[ @]}"
do
result=$(ssh -T $i "cat /proc/loadavg" 2>&1)
#the result can be parsed and some alerts issued or action taken
dt=`date +'%Y-%m-%d %H:%M'`
#append it into log file
echo "$dt $result" >> /user/name/cpumon/$i
done

Top News