Does that syntax work? I was only able to get the check for my configuration to work with a for loop:
if failed unixsocket /var/run/postgresql/.s.PGSQL.5432 protocol pgsql retry 2 for 2 times within 2 cycles then restart

The retry should retry that many times within 1 cycle, and the for loop would make sure it has tried to connect for 2 cycles in a row before it takes action (with the same retry). so, I'm thinking it translates into option 3. For the 3rd one to alert on the 3rd attempt I would probably run the same if with the numbers increased to 3:
if failed unixsocket /var/run/postgresql/.s.PGSQL.5432 protocol pgsql retry 2 for 3 times within 3 cycles then alert

You may not need that line though, as monit will check for existence by default and I have gotten alerts that a process failed to start and on the next cycle monit saw that the process didn't exist and tried to start it a second time which usually succeeds. After a number of attempts if a timeout is setup then you'll get an alert that it reached max attempts and it needs manual attention.

If you have the webpage setup in the config you should be able to go to the address:port in your browser and it'll show you the processes it is monitoring and how it has interpreted your command. in my install it's http://<ip>:2812

[email protected]
Toll Free: 866-858-5864
www.Konasports.com

On 10/5/2011 6:14 AM, Mark Olliver wrote:

Hi,

 

I am a little unsure on the retry / restart rules, I have checked the config below and it is valid my question is does it mean that it will restart after which of the following:

1, 2 failed connection attempts in 1 cycle

2, 2 failed connection attempts in either cycle

3, 4 failed connection attempts over 2 cycles

 

Ideally I would want option 3. I then want it to alert me should it then still be failing on the 3 cycle as that probably means I need manual intervention.

 

set mail-format {

    from: [email protected]

    subject: $SERVICE $HOST

    message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.

    }

 

check process postgresql with pidfile /var/run/postgresql/8.4-main.pid

    start program = "/etc/init.d/postgresql-8.4 start"

    stop  program = "/etc/init.d/postgresql-8.4 stop"

    if failed unixsocket /var/run/postgresql/.s.PGSQL.5432 protocol pgsql retry 2 2 cycles then restart

    if failed unixsocket /var/run/postgresql/.s.PGSQL.5432 protocol pgsql 3 cycles then alert

    if failed host localhost port 5432 protocol pgsql retry 2 2 cycles then restart

    if failed host localhost port 5432 protocol pgsql 3 cycles then alert

    alert [email protected]

    group database

 

Thanks

 

Mark



--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1809 / Virus Database: 2085/4537 - Release Date: 10/04/11


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to