4

In the monit config file, we have a list of processes we expect monit to check for. Each one looks like:

check process process_name_here
  with pidfile /path/to/file.pid
  start program = "/bin/bash ..."
  stop program = "/bin/bash ..."
  if totalmem is greater than X MB for Y cycles then alert
  if N restarts within X cycles then alert
  group group_name

Since we have about 30-40 processes in this list that we monitor, I have two questions:

1) If we restart the services (kill them all), can we have monit start all processes at the same time instead of the way it's done now (sequentially, one by one).

2) Can we specify the order in which we would like the processes to start? How is the order determined? Is it the order that they appear in the conf file? Is it by process name? Anything else? This is especially important if #1 above is not possible...

Michael Y.
  • 661
  • 7
  • 12

2 Answers2

1

You can use the depends on syntax. I use this for custom Varnish builds.

For example, process a, process b, and process c. Process a needs to start first, then followed by b and c.

Your first process won't depend on anything. In your check for process b, you'll want:

depends on process a

Then in your process c check, you'll want:

depends on process b

This should make sure that the processes are started in the correct order. Let me know if this works for you.

0

Going only by documentation, there is nothing related to point one other than the fact that monit runs single-threaded.

As for point two, under "SERVICE POLL TIME":

Checks are performed in the same order as they are written in the .monitrc file, except if dependencies are setup between services, in which case the services hierarchy may alternate the order of the checks.

Note that if you have an include string that matches multiple files they are included in no specific order.

If you require a specific order you should use DEPENDS where possible

zeeZ
  • 46
  • 3