1

I'm monitoring mysqld with monit but I would like that if I stop monit then the mysqld service also stops.

womble
  • 95,029
  • 29
  • 173
  • 228
edotan
  • 1,786
  • 12
  • 37
  • 57

4 Answers4

4

The easy way to do this is to modify the Monit init.d script to also stop mysqld. The main problem with this is that future updates to the Monit package may overwrite your changes.

Alternatively, you could write your own init.d script that controls mysqld and monit, and use that instead of the provided init.d scripts.

Kyle Smith
  • 9,563
  • 1
  • 30
  • 32
2

You fundamentally can't, and shouldn't want to, because that's not the way monit is designed to work. Monit is, as the name suggests, a monitoring system, that has some automatic problem-handling logic built-in. I also can't imagine why you'd want to do something like this, so I'm at a loss to give you alternative solutions to your actual problem.

womble
  • 95,029
  • 29
  • 173
  • 228
0

This might be a a bit simplistic, but have you thought about this:

create a script that just stops/starts both services at the same time, and use that to call them instead of the regular init.d scripts?

You could put them into your bin folder if you want to be able to run them as a command.

Lucas Kauffman
  • 16,818
  • 9
  • 57
  • 92
0

Is it because you want to stop MySQL and do maintenance or whatever?

If so, just:

'monit unmonitor name_of_service_check_here'

... and monit will leave it be. If you have configured a monit state file (defaults to /var/.monit_state or something), then monit remembers unmonitors and such even after a reboot. You might also want to try the monit status to see current status for all or one given check:

monit status

Like Womble said, start by explaining what problem you have instead of focusing on one (probably bad) work-around.

3molo
  • 4,340
  • 5
  • 30
  • 46