Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm look for shell script to send Top processes as an email when Monitor CPU load average exceed 20 I'm running RedHat 6.

share|improve this question
    
serverfault.com/questions/318588/… –  quanta Feb 26 '13 at 7:43

1 Answer 1

uptime | awk '$NF >= 20 { system("top -cSb n 1") }' \
    | tail -n +8 | sort -rn -k11 | head \
        | mail -s "PROBLEM Service Alert: load_fifteen is CRITICAL" email@domain
  • NF stands for Number of Fields. $NF get the value of the last field. This is the system load average for past 15 minutes
  • top -b to run in batch mode, for sending output to stdout
  • tail -n +8 | sort -rn -k11 | head: remove the headers, then sort by CPU Time, and get the top processes.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.