Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- loadthreashold = 0.05
- ioprocthreshold = 20
- cpuprocthreashold = 35.0
- cpuprocreset = 5.0
- reniceto = 10
- while true
- do
- i = `cat /proc/loadavg | awk -F ' ' '{if ( $1 > $loadthreashold) print $1}'`
- if [ $i -gt $loadthreashold ]
- then
- echo "Load $i exceeds threashold of $loadthreashold"
- for i in `iotop -P -b -q -o -d 0.1 -n 5 | awk -F ' ' '{if ( $1 ~ /[0-9]/ && $10 > $ioprocthreshold && $2 == "be/0") print $1}'`
- do
- ionice -c 3 -p $i
- echo "process $i reniced to idel as it was hogging io"
- done
- for i in `top -b -d 0.1 -n 5 | awk -F ' ' '{if ( $1 ~ /[0-9]/ && $4 == 0 && $9 > $cpuprocthreashold) print $1}'`
- do
- renice -n $reniceto -p $i
- echo "process $i reniced to $reniceto as it was hogging cpu"
- done
- for i in `top -b -d 0.1 -n 1 | awk -F ' ' '{if ( $1 ~ /[0-9]/ && $4 == $reniceto && $9 < $cpuprocreset) print $1}'`
- do
- renice -n 0 -p $i
- echo "process $i reniced to 0 as it stopped hogging cpu"
- done
- fi
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment