0
votes

I am looking for a service that monitors the CPU of a Unix computer (and that can react according to the load) and thought that Monit could do the job but I am in a difficult situation:

I need, according to the CPU load level (>50% / >75% / >95%), different actions. I wrote those lines:

check system $HOST
    if cpu > 50% then exec "one.sh"
    if cpu > 75% then exec "two.sh"
    if cpu > 95% then exec "three.sh"

But when the CPU load is higher than 95%, monit launches the 3 scripts. I want to monit to launches one the 3 scripts, according to the CPU load.

I looked for embedded if with monit but it does not seem to exist. Otherwise it would have been simple.

Do you have any idea how to make it work?

Have a nice day!

Bibio

2

2 Answers

0
votes

What about something like this?

check system $HOST
        if cpu > 95% then exec "three.sh" 
        if cpu > 75% then 
          if cpu < 95% then exec "two.sh"
        if cpu > 50% then 
          if cpu < 75% then exec "two.sh"
0
votes

If CPU usage more than 95%, it will always execute all the three scripts.

Better you can prioritize the status in your scripts.

But I am sure, if your CPU usage is between 50-70% for longer run, then it will execute the first scripts (one.sh) alone.