Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using a tool like top or htop, is it possible to monitor CPU usage and execute a script if CPU usage exceeds a certain amount?

share|improve this question

This would be trivial using a tool like monit.

check system myhost
    if cpu usage (system) > 80% for 4 cycles then alert
    if cpu usage (user) > 80% for 5 cycles then alert
    if cpu usage (wait) > 90% for 5 cycles then alert
share|improve this answer
  1. Cfengine can do with classes and variables. Classes use standard deviation which is more flexible that hard limits.

  2. I think you can do this with net-snmp too.

  3. You can pull loads from sysstat.

  4. Raw numbers in /proc/loadavg.

share|improve this answer

Your Answer


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.