2

I want to execute a script when monit is restarted. For my case, this mostly applies to the restart of the whole server.

How can I achieve this? Is there a way beside monit to do this?

Background: The server, where I need this, is a virtual server. It seems, that firewall rules in iptables are not persistant, so I need to set them on server start.

Martin
  • 153
  • 6
  • Perhaps you should ask how to make the `iptables` firewall rules persistent, then, instead of this question? – Michael Hampton Jul 30 '12 at 05:32
  • This would be an approach. But I'm using monit to start all services and check some things, so I would like to do this in there to keep things together. – Martin Jul 30 '12 at 06:54
  • The Linux system will already have a "standard" way of persisting iptables, and it's usually best to use the normal ways. Otherwise you will end up with confusion later. – Michael Hampton Jul 30 '12 at 07:12

1 Answers1

1

By default, you should receive an alert that the Monit daemon restarted. Something like:

Monit instance changed Service localhost

    Date:        Sun, 29 Jul 2012 13:09:28
    Action:      start
    Host:        ppro.abc123.com
    Description: Monit started

Your faithful employee,
Monit

If you need something to run at boot, have you considered wrapping it in an init script? With Monit, there's a level of uptime testing, but it only applies to processes.

You could also choose to take an action on a change in Monit's PID... But I think it would help to get a better understanding of what you need to execute.

ewwhite
  • 194,921
  • 91
  • 434
  • 799