28 lines
632 B
Bash
28 lines
632 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
i=1
|
||
|
j=1
|
||
|
threshold=850
|
||
|
while [ 2 -gt 1 ]; do
|
||
|
echo "run count: $i"
|
||
|
sleep 30
|
||
|
mem=$(free -m | grep + | awk '{print $3}')
|
||
|
echo " used memory: $mem"
|
||
|
echo " threshold: $threshold"
|
||
|
if [ $mem -gt $threshold ]; then
|
||
|
echo " memory usage too high"
|
||
|
echo " too high mem count: $j (apache will be restarted if count reaches 10)"
|
||
|
let j++
|
||
|
if [ $j -gt 10 ]; then
|
||
|
echo " resetting apache to clear memory"
|
||
|
/etc/init.d/apache2 restart
|
||
|
j=1
|
||
|
fi
|
||
|
else
|
||
|
echo " memory below threshold"
|
||
|
fi
|
||
|
let i++
|
||
|
done
|
||
|
|
||
|
exit 0
|