0

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?

slm
  • 7,615
  • 16
  • 56
  • 76
James Sun
  • 101
  • 2

2 Answers2

1

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
Zoredache
  • 130,897
  • 41
  • 276
  • 420
0
  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.

Neil H Watson
  • 448
  • 1
  • 5
  • 18