in /etc/crontab :

*/3 * * * * root /usr/local/bin/check_la.sh

------------------------------------------

/usr/local/bin/check_la.sh :

if [[ $(uptime | sed -e 's/.*average:\ \(.*\)\..*,.*,.*/\1/') -ge 16 ]]; then

/usr/local/bin/stat.sh > /var/tmp/stat-$(date "+%Y_%d_%m-%H:%M")

fi

-----------------------------------------

/usr/local/bin/stat.sh :

#!/bin/sh

make_stat() {
        echo -e "\n\n\n========================= processes ===================\n"
        ps wwaux
        echo -e "\n\n\n========================= http requests ===================\n"
        links -dump http://localhost/server-status
        echo -e "\n\n\n========================= mysql threads ==================="
        mysql -u root --exec "SHOW FULL PROCESSLIST"
        echo -e "\n\n\n========================= network connections ===================\n"
        netstat -ant
        echo -e "\n\n\n========================= memory ===================\n"
        free
        echo -e "\n\n###############################################\n\n"
}


if [ $(ps aux | grep apache | wc -l) -ge 2 -a  $(ps aux | grep mysql | grep -v grep | wc -l) -ge 0 ] ; then
        outfile=${1:-/dev/stdout}
        cat /dev/null > $outfile
        make_stat >> $outfile
fi