Monit multiple processes with same name
Asked Answered
C

1

6

I'm new to Monit and trying to understand if it offers a way to handle multiple processes of the same name where the PIDs are unknown. My ideal Monit behaviour would be:

Watch every process with the name 'x' and restart any of them for which memory usage exceeds X

If that's not possible, I'd also settle for:

Watch every process with the name 'x' and restart ALL of them if ANY of them's memory usage exceeds X

Most of the Monit examples I see depend on PIDs or expect only one process will have the specified name.

I'm also interested in suggestions of other tools which may be better suited than Monit.

Thanks!

Constellation answered 18/3, 2016 at 15:34 Comment(0)
E
0

You should be able to do something like this:

CHECK PROCESS banbylog MATCHING "java.*banbylog" start program = "/frankie/_banbylog.sh"
    if memory usage > 70% MB for 5 cycles then restart
    if memory usage > 4 GB for 5 cycles then restart

I dwell a bit more on how to catch processes by regex here. The format above wasn’t tested. Let me know if it doesn’t work.

Ideally, on the regex, you can catch something unique to each process as if you don’t monit will choose the oldest one.

Ellita answered 17/10, 2022 at 1:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.