I'm monitoring mysqld with monit but I would like that if I stop monit then the mysqld service also stops.
4 Answers
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.
![](../../users/profiles/23124.webp)
- 9,563
- 1
- 30
- 32
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.
![](../../users/profiles/1375.webp)
- 95,029
- 29
- 173
- 228
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.
![](../../users/profiles/86280.webp)
- 16,818
- 9
- 57
- 92
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.
![](../../users/profiles/24836.webp)
- 4,340
- 5
- 30
- 46