I'm trying to send an email through cron to know what processes are hogging my server. It works fine but the resulting email is too narrow and I need to know more about the process.
This is the script I'm using (stole it from here: http://www.inmotionhosting.com/support/website/server-usage/create-server-load-monitoring-bash-script):
#!/bin/bash
trigger=10.00
load=`cat /proc/loadavg | awk '{print $1}'`
response=`echo | awk -v T=$trigger -v L=$load 'BEGIN{if ( L > T){ print "greater"}}'`
if [[ $response = "greater" ]]
then
top -cSbn 1 | head -14 | tail -8 | mail -s"High load on server - [ $load ]" myemail@domain.com
fi
The resulting email is something like:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
810809 root 20 0 20700 13m 3032 R 50 0.0 0:00.40 /prod/process-nam
810802 root 20 0 20700 13m 3032 R 48 0.0 0:00.39 /prod/process-nam
810808 root 20 0 20708 13m 3032 S 48 0.0 0:00.35 /prod/process-nam
810803 root 20 0 20708 13m 3032 S 46 0.0 0:00.39 /prod/process-nam
810810 root 20 0 20168 13m 3028 R 46 0.0 0:00.33 /prod/process-nam
318723 www-data 20 0 146m 131m 3320 R 45 0.4 67:27.96 /home/server/pr
810800 root 20 0 20704 13m 3032 S 45 0.0 0:00.39 /prod/process-nam
As you can see, the whole path is missing. But if i run the script from bash, it works, sending an email wide enough.
Is it a ncurses issue? Pipe mail issue?
Thanks!