monit start/stop in a synchronous mode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

monit start/stop in a synchronous mode

Alainkr
Hello,

Is there a way to monit start/stop a process in a synchronous fashion ?

Thanks 

Alain


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

martinp@tildeslash.com
Hello Alain,

try Monit 5.9 - it runs the stop+start programs serially and waits for their exit.

Regards,
Martin


On 10 Oct 2014, at 15:56, Alain Kreienbuhl <[hidden email]> wrote:

> Hello,
>
> Is there a way to monit start/stop a process in a synchronous fashion ?
>
> Thanks
>
> Alain
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

Alainkr
Hello,

Just tried 5.9 and I’m still getting the same behavior.
I’m using debian wheezy.  I compiled monit 5.9 from the source.

Thanks for your help

Alain
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

martinp@tildeslash.com
Hello Alain,

please can you run monit 5.9 in verbose mode, restart the service using either GUI or CLI (CLI will need different terminal and -I will run monit in foreground) and provide output?:

        monit -vI

Regards,
Martin



On 10 Oct 2014, at 21:54, Alainkr <[hidden email]> wrote:

> Hello,
>
> Just tried 5.9 and I’m still getting the same behavior.
> I’m using debian wheezy.  I compiled monit 5.9 from the source.
>
> Thanks for your help
>
> Alain
>
>
>
> --
> View this message in context: http://nongnu.13855.n7.nabble.com/monit-start-stop-in-a-synchronous-mode-tp190714p190721.html
> Sent from the monit-general mailing list archive at Nabble.com.
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

Alainkr
Hello Martin,

I hope I understand you correctly. What I did was  stop monit. Thru the /etc/init.d/monit stop script that I keep from monit 5.4 ( is that ok by the way ? )

Then, on one terminal I started up monit in verbose forground : 
sudo monit -vI
Adding host allow 'localhost'
Skipping redundant host 'localhost'
Skipping redundant host 'localhost'
Skipping redundant host 'localhost'
Skipping redundant host 'localhost'
Skipping redundant host 'localhost'
Runtime constants:
 Control file       = /etc/monitrc
 Log file           = /var/log/monit.log
 Pid file           = /run/monit.pid
 Id file            = /var/lib/monit/id
 State file         = /var/lib/monit/state
 Debug              = True
 Log                = True
 Use syslog         = False
 Is Daemon          = True
 Use process engine = True
 Poll time          = 60 seconds with start delay 0 seconds
 Expect buffer      = 256 bytes
 Event queue        = base directory /var/lib/monit/events with 100 slots
 Mail server(s)     = smtp.gmail.com:587(ssl) with timeout 30 seconds
 Mail from          = monit@$HOST
 Mail subject       = monit alert --  $HOST $SERVICE $EVENT
 Mail message       = $EVENT Service $SERV..(truncated)
 Start monit httpd  = True
 httpd bind address = localhost
 httpd portnumber   = 2812
 httpd signature    = True
 Use ssl encryption = False
 httpd auth. style  = Host/Net allow list
 Alert mail to      = [hidden email]
   Alert on         = Checksum Connection Content Data Exec Fsflags Gid Icmp Invalid Nonexist Permission PID PPID Resource Size Status Timeout Timestamp Uid Uptime

The service list contains the following entries:

Process Name          = sshd
 Group                = sshd, system
 Pid file             = /var/run/sshd.pid
 Monitoring mode      = active
 Start program        = '/etc/init.d/ssh start' timeout 30 second(s)
 Stop program         = '/etc/init.d/ssh stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Depends on Service   = sshd_dsa_key
 Depends on Service   = sshd_rsa_key
 Depends on Service   = sshd_rc
 Depends on Service   = sftp_bin
 Depends on Service   = sshd_bin
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 Port                 = if failed [localhost:2222 [SSH via TCP] with timeout 5000 seconds] then restart
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = sshd_bin
 Group                = sshd
 Path                 = /usr/sbin/sshd
 Monitoring mode      = active
 Existence            = if does not exist then restart

File Name             = sftp_bin
 Group                = sshd
 Path                 = /usr/lib/openssh/sftp-server
 Monitoring mode      = active
 Existence            = if does not exist then restart

File Name             = sshd_rsa_key
 Group                = sshd
 Path                 = /etc/ssh/ssh_host_rsa_key
 Monitoring mode      = active
 Existence            = if does not exist then restart

File Name             = sshd_dsa_key
 Group                = sshd
 Path                 = /etc/ssh/ssh_host_dsa_key
 Monitoring mode      = active
 Existence            = if does not exist then restart

File Name             = sshd_rc
 Group                = sshd
 Path                 = /etc/ssh/sshd_config
 Monitoring mode      = active
 Existence            = if does not exist then restart

Process Name          = myappzoo
 Group                = myappzoo
 Pid file             = /home/myappzoo/zookeeper/zookeeper.pid
 Monitoring mode      = manual
 Start program        = '/etc/init.d/myappzoo start' timeout 30 second(s)
 Stop program         = '/etc/init.d/myappzoo stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 CPU usage limit      = if greater than 80.0% for 5 cycles then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = myappzoolog
 Group                = myappzoo
 Path                 = /home/myappzoo/zookeeper/logs/zookeeper.log
 Monitoring mode      = manual
 Existence            = if does not exist then restart
 Depends on Service   = myappzoo
 Pattern              = if match "WARN" then alert
 Pattern              = if match "WARN" for 10 cycles then unmonitor
 Pattern              = if match "ERROR" then alert
 Pattern              = if match "ERROR" for 10 cycles then unmonitor
 Pattern              = if match "OutOfMemoryError" then alert
 Pattern              = if match "OutOfMemoryError" then restart

Process Name          = myappca2
 Group                = myappca2
 Pid file             = /home/myappca2/cassandra/cassandra.pid
 Monitoring mode      = manual
 Start program        = '/etc/init.d/myappca2 start' timeout 30 second(s)
 Stop program         = '/etc/init.d/myappca2 stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 CPU usage limit      = if greater than 80.0% for 5 cycles then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = myappca2log
 Group                = myappca2
 Path                 = /home/myappca2/cassandra/logs/system.log
 Monitoring mode      = manual
 Existence            = if does not exist then restart
 Depends on Service   = myappca2
 Pattern              = if match "ERROR" then alert
 Pattern              = if match "ERROR" for 10 cycles then unmonitor
 Pattern              = if match "OutOfMemoryError" then alert
 Pattern              = if match "OutOfMemoryError" then restart

Process Name          = myappca1
 Group                = myappca1
 Pid file             = /home/myappca1/cassandra/cassandra.pid
 Monitoring mode      = manual
 Start program        = '/etc/init.d/myappca1 start' timeout 30 second(s)
 Stop program         = '/etc/init.d/myappca1 stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 CPU usage limit      = if greater than 80.0% for 5 cycles then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = myappca1log
 Group                = myappca1
 Path                 = /home/myappca1/cassandra/logs/cassandra.log
 Monitoring mode      = manual
 Existence            = if does not exist then restart
 Depends on Service   = myappca1
 Pattern              = if match "ERROR" then alert
 Pattern              = if match "ERROR" for 10 cycles then unmonitor
 Pattern              = if match "OutOfMemoryError" then alert
 Pattern              = if match "OutOfMemoryError" then restart

Process Name          = myappcol
 Group                = myappcol
 Pid file             = /home/myappcol/tomcat/tomcat.pid
 Monitoring mode      = manual
 Start program        = '/etc/init.d/myappcol start' timeout 30 second(s)
 Stop program         = '/etc/init.d/myappcol stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 CPU usage limit      = if greater than 80.0% for 5 cycles then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

Process Name          = myappgui
 Group                = myappgui
 Pid file             = /home/myappgui/tomcat/tomcat.pid
 Monitoring mode      = manual
 Start program        = '/etc/init.d/myappgui start' timeout 30 second(s)
 Stop program         = '/etc/init.d/myappgui stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 CPU usage limit      = if greater than 80.0% for 5 cycles then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

Process Name          = myappapi
 Group                = myappapi
 Pid file             = /home/myappapi/tomcat/tomcat.pid
 Monitoring mode      = manual
 Start program        = '/etc/init.d/myappapi start' timeout 30 second(s)
 Stop program         = '/etc/init.d/myappapi stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 CPU usage limit      = if greater than 80.0% for 5 cycles then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

Process Name          = myappsyp
 Group                = myappsyp
 Pid file             = /home/myappsyp/tomcat/tomcat.pid
 Monitoring mode      = manual
 Start program        = '/etc/init.d/myappsyp start' timeout 30 second(s)
 Stop program         = '/etc/init.d/myappsyp stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 CPU usage limit      = if greater than 80.0% for 5 cycles then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = myappcol-log
 Group                = myappcol
 Path                 = /home/myappcol/tomcat/logs/catalina.out
 Monitoring mode      = manual
 Existence            = if does not exist then restart
 Depends on Service   = myappcol
 Pattern              = if match "ERROR" then alert
 Pattern              = if match "ERROR" for 10 cycles then unmonitor
 Pattern              = if match "OutOfMemoryError" then exec '/etc/init.d/myappcol restart' timeout 0 cycle(s)

File Name             = myappgui-log
 Group                = myappgui
 Path                 = /home/myappgui/tomcat/logs/catalina.out
 Monitoring mode      = manual
 Existence            = if does not exist then restart
 Depends on Service   = myappgui
 Pattern              = if match "ERROR" then alert
 Pattern              = if match "ERROR" for 10 cycles then unmonitor
 Pattern              = if match "OutOfMemoryError" then exec '/etc/init.d/myappgui restart' timeout 0 cycle(s)

File Name             = myappapi-log
 Group                = myappapi
 Path                 = /home/myappapi/tomcat/logs/catalina.out
 Monitoring mode      = manual
 Existence            = if does not exist then restart
 Depends on Service   = myappapi
 Pattern              = if match "ERROR" then alert
 Pattern              = if match "ERROR" for 10 cycles then unmonitor
 Pattern              = if match "OutOfMemoryError" then exec '/etc/init.d/myappapi restart' timeout 0 cycle(s)

File Name             = myappsyp-log
 Group                = myappsyp
 Path                 = /home/myappsyp/tomcat/logs/catalina.out
 Monitoring mode      = manual
 Existence            = if does not exist then restart
 Depends on Service   = myappsyp
 Pattern              = if match "ERROR" then alert
 Pattern              = if match "ERROR" for 10 cycles then unmonitor
 Pattern              = if match "OutOfMemoryError" then exec '/etc/init.d/myappsyp restart' timeout 0 cycle(s)

Process Name          = crond
 Group                = crond, system
 Pid file             = /var/run/crond.pid
 Monitoring mode      = active
 Start program        = '/etc/init.d/cron start' timeout 30 second(s)
 Stop program         = '/etc/init.d/cron stop' timeout 30 second(s)
 Existence            = if does not exist then restart
 Depends on Service   = cron_spool
 Depends on Service   = cron_rc
 Depends on Service   = cron_bin
 Pid                  = if changed then alert
 PPid                 = if changed then alert
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = cron_bin
 Group                = crond
 Path                 = /usr/sbin/cron
 Monitoring mode      = active
 Existence            = if does not exist then restart

File Name             = cron_rc
 Group                = crond
 Path                 = /etc/init.d/cron
 Monitoring mode      = active
 Existence            = if does not exist then restart

Directory Name        = cron_spool
 Group                = crond
 Path                 = /var/spool/cron/crontabs
 Monitoring mode      = active
 Existence            = if does not exist then restart
 Permission           = if failed 1730 then unmonitor
 UID                  = if failed 0 then unmonitor
 GID                  = if failed 102 then unmonitor

System Name           = box2
 Monitoring mode      = active

-------------------------------------------------------------------------------
pidfile '/run/monit.pid' does not exist
Starting Monit 5.9 daemon with http interface at [localhost:2812]
Starting Monit HTTP server at [localhost:2812]
Monit HTTP server started
'box2' Monit started
'sshd_bin' file exists check succeeded
'sshd_bin' is a regular file or socket
'sftp_bin' file exists check succeeded
'sftp_bin' is a regular file or socket
'sshd_rsa_key' file exists check succeeded
'sshd_rsa_key' is a regular file or socket
'sshd_dsa_key' file exists check succeeded
'sshd_dsa_key' is a regular file or socket
'sshd_rc' file exists check succeeded
'sshd_rc' is a regular file or socket
'cron_bin' file exists check succeeded
'cron_bin' is a regular file or socket
'cron_rc' file exists check succeeded
'cron_rc' is a regular file or socket
'cron_spool' directory exists check succeeded
'cron_spool' is directory
'cron_spool' permission check succeeded [current permission=1730]
'cron_spool' uid check succeeded [current uid=0]
'cron_spool' gid check succeeded [current gid=102]
'sshd' zombie check succeeded [status_flag=0000]
'sshd' succeeded connecting to INET[localhost:2222] via TCP
'sshd' succeeded testing protocol [SSH] at INET[localhost:2222] via TCP
'crond' zombie check succeeded [status_flag=0000]
//// after input in other term
'myappcol' stop on user request
Monit daemon with PID 4714 awakened
Awakened by User defined signal 1
'myappcol-log' stop skipped -- method not defined
'myappcol' stop: /etc/init.d/myappcol
In another terminal : 
sudo monit stop myappcol

Command returned immediately despite a long sleep in the stop script (for testing).

This is Monit version 5.9
Copyright (C) 2001-2014 Tildeslash Ltd. All Rights Reserved.
Linux box2 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux

Thanks for your help

Alain



2014-10-13 11:52 GMT+02:00 Martin Pala [via nongnu] <[hidden email]>:
Hello Alain,

please can you run monit 5.9 in verbose mode, restart the service using either GUI or CLI (CLI will need different terminal and -I will run monit in foreground) and provide output?:

        monit -vI

Regards,
Martin



On 10 Oct 2014, at 21:54, Alainkr <[hidden email]> wrote:

> Hello,
>
> Just tried 5.9 and I’m still getting the same behavior.
> I’m using debian wheezy.  I compiled monit 5.9 from the source.
>
> Thanks for your help
>
> Alain
>
>
>
> --
> View this message in context: http://nongnu.13855.n7.nabble.com/monit-start-stop-in-a-synchronous-mode-tp190714p190721.html
> Sent from the monit-general mailing list archive at Nabble.com.
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


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



If you reply to this email, your message will be added to the discussion below:
http://nongnu.13855.n7.nabble.com/monit-start-stop-in-a-synchronous-mode-tp190714p190776.html
To unsubscribe from monit start/stop in a synchronous mode, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

martinp@tildeslash.com

On 13 Oct 2014, at 14:12, Alainkr <[hidden email]> wrote:

> Hello Martin,
>
> I hope I understand you correctly. What I did was  stop monit. Thru the /etc/init.d/monit stop script that I keep from monit 5.4 ( is that ok by the way ? )


Yes, no problem with the 5.4 init script, 5.9 is fully backward compatible


> 'myappcol' stop on user request
> Monit daemon with PID 4714 awakened
> Awakened by User defined signal 1
> 'myappcol-log' stop skipped -- method not defined
> 'myappcol' stop: /etc/init.d/myappcol

> In another terminal :
> sudo monit stop myappcol
>
> Command returned immediately despite a long sleep in the stop script (for testing).

OK, there was probably misunderstanding: the processing of stop/start/restart commands is synchronous internally in Monit and if the service is process type, Monit (5.9+) always waits for the program to finish and process to stop/start (by observing its PID on stop or checking for process on start). Older Monit versions did the same sequence, but used shortcut by not waiting for the program to finish and only observed the PID (this was problem on some platforms) - for non-process types it just executed the program and didn't wait for it to finish (5.9 waits regardless of service type). Note: there is also timeout associated with the command (by default 30 seconds).

The CLI however doesn't wait for the requested action to finish - when you do for example "monit stop myappcol" it sends command to Monit to do the work and returns immediately. Monit wakes up when it receives the command and performs the requested action on background.

If i understand you corrently, you wanted CLI to not return before the action is done by Monit?



> 2014-10-13 11:52 GMT+02:00 Martin Pala [via nongnu] <[hidden email]>:
> Hello Alain,
>
> please can you run monit 5.9 in verbose mode, restart the service using either GUI or CLI (CLI will need different terminal and -I will run monit in foreground) and provide output?:
>
>         monit -vI
>
> Regards,
> Martin
>
>
>
> On 10 Oct 2014, at 21:54, Alainkr <[hidden email]> wrote:
>
> > Hello,
> >
> > Just tried 5.9 and I’m still getting the same behavior.
> > I’m using debian wheezy.  I compiled monit 5.9 from the source.
> >
> > Thanks for your help
> >
> > Alain
> >
> >
>


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

Alainkr
Martin Pala wrote
If i understand you corrently, you wanted CLI to not return before the action is done by Monit?
Thinking about it there's 2 aspect to it :

(1) Wait until invocation of the "stop program" returns
(2) Wait until the PID as specified in the pid file finishes

both are interesting. My primary need was for (1).

Sorry to make things complicated :-)

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

martinp@tildeslash.com

On 14 Oct 2014, at 11:18, Alainkr <[hidden email]> wrote:

> Martin Pala wrote
>> If i understand you corrently, you wanted CLI to not return before the
>> action is done by Monit?
>
> Thinking about it there's 2 aspect to it :
>
> (1) Wait until invocation of the "stop program" returns
> (2) Wait until the PID as specified in the pid file finishes
>
> both are interesting. My primary need was for (1).

Monit 5.9 uses both steps for start/stop/restart programs - unline the "exec" action in the test rule, which returns immediately and lets the program finish on the background.

I recommend to modify the configuration like this:

--8<--
check file myappcol-log with path  /home/myappcol/tomcat/logs/catalina.out
        mode manual
        group myappcol
        depends on myappcol
        if match "ERROR" then alert
        if match "ERROR" for 10 cycles then unmonitor
        if match "OutOfMemoryError" then exec '/usr/bin/monit restart myappcol'    # note: this restarts the myappcol service via monit (fix the monit path if not present in /usr/bin/)
--8<--

Regards,
Martin


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

Alainkr
Thanks for you reply Martin but I thing you mixed your reply with another post I had.

My issue here is that /usr/bin/monit stop myservice
returns immediately and doesn't wait for /etc/init.d/myservice stop to complete.

Is there a my to have monit cli wait (i've tried -I  but to now avail )

Thanks again

Alain
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

martinp@tildeslash.com

On 14 Oct 2014, at 13:46, Alainkr <[hidden email]> wrote:

> Thanks for you reply Martin but I thing you mixed your reply with another
> post I had.
>
> My issue here is that /usr/bin/monit stop myservice
> returns immediately and doesn't wait for /etc/init.d/myservice stop to
> complete.
>
> Is there a my to have monit cli wait (i've tried -I  but to now avail )
>
> Thanks again
>
> Alain

We have added the CLI wait and result report feature to our TODO list, currently the CLI just schedules the action and returns immediately.

As a workaround it could be possible to write script which will call "monit stop service" + then won't return immediately but will poll "monit summary" or "monit status" to observe the service status and return after the stop finished.

Best regards,
Martin


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

repeated file content match

Ben Soot
In reply to this post by martinp@tildeslash.com
Hello,

What is the best way to get alerts of repeated file content matches?

I have 2 rules one for the same file so i can then distinguish in mmonit the service to send alerts
to different mail addresses.

Somehow the alerts for the repeated rule are not triggered... Anybody done sth like this?
also i never got the service group

Im using monit 5.4 and mmonit 3.1.2


thanks Ben


set daemon  120
...


check file foo.log  with path /home/foo.log

     if match
           "^.*ACTION_REQUIRED.*$" then alert

check file foo_REPEATED.log  with path /home/foo.log
     group repeatedfailure
     if match
           "^.*ACTION_REQUIRED.*$" within 3 cycles then alert



--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: repeated file content match

martinp@tildeslash.com
Hello Ben,

i didn't try such configuration but it looks fine and should work ... it depends however what you expect from it. It won't work as plain cross-cycle strings counter, but as indicator that the string showed up again in 3 consecutive cycles.

The "foo_REPEATED.log" service condition requires match in 3 consecutive cycles to trigger the alert and it doesn't matter how many matches there were in 1 (partial) cycle: if there are multiple matches in only one test cycle (for example 20x "ACTION_REQUIRED" string), given cycle matched - Monit will record the read position (end of the file) and the next cycle will start from where it stopped before. In order for the next cycle to match, new instance of "ACTION_REQUIRED" string had to be appended to the file again (at least one instance) - then this cycle will match too. And if this will occur 3rd time (again new occurrence of "ACTION_REQUIRED" string in cycle no. 3), then Monit will trigger the alert.

If you need to count the messages and trigger the alert anytime there are 3+ occurrences of the same string (even in the same cycle), it cannot be achieved with this configuration ... it would require new option for the content test (some counter test for the given pattern).

Regards,
Martin


> On 20 Oct 2014, at 15:11, Ben Soot <[hidden email]> wrote:
>
> Hello,
>
> What is the best way to get alerts of repeated file content matches?
>
> I have 2 rules one for the same file so i can then distinguish in mmonit the service to send alerts to different mail addresses.
>
> Somehow the alerts for the repeated rule are not triggered... Anybody done sth like this?
> also i never got the service group
>
> Im using monit 5.4 and mmonit 3.1.2
>
>
> thanks Ben
>
>
> set daemon  120
> ...
>
>
> check file foo.log  with path /home/foo.log
>
>    if match
>          "^.*ACTION_REQUIRED.*$" then alert
>
> check file foo_REPEATED.log  with path /home/foo.log
>    group repeatedfailure
>    if match
>          "^.*ACTION_REQUIRED.*$" within 3 cycles then alert
>
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: repeated file content match

Ben Soot
Hi Martin,

Thanks for the answer and sry for my late reply:

I finally got it to work, it was an issue with the syntax (one needs to use "for 3 cycles" instead
of "within 3 cycles" as an action condition clause). This is unclear from the documentation IMO.
Here is my working version:


  check file foo.log  with path /home/foo.log

      if match
            "^.*ACTION_REQUIRED.*$" then alert

  check file foo_REPEATED.log  with path /home/foo.log
      group repeatedfailure
      if match
            "^.*ACTION_REQUIRED.*$" for 3 cycles then alert



Cheers Ben

On 22.10.2014 10:35, Martin Pala wrote:

> Hello Ben,
>
> i didn't try such configuration but it looks fine and should work ... it depends however what you expect from it. It won't work as plain cross-cycle strings counter, but as indicator that the string showed up again in 3 consecutive cycles.
>
> The "foo_REPEATED.log" service condition requires match in 3 consecutive cycles to trigger the alert and it doesn't matter how many matches there were in 1 (partial) cycle: if there are multiple matches in only one test cycle (for example 20x "ACTION_REQUIRED" string), given cycle matched - Monit will record the read position (end of the file) and the next cycle will start from where it stopped before. In order for the next cycle to match, new instance of "ACTION_REQUIRED" string had to be appended to the file again (at least one instance) - then this cycle will match too. And if this will occur 3rd time (again new occurrence of "ACTION_REQUIRED" string in cycle no. 3), then Monit will trigger the alert.
>
> If you need to count the messages and trigger the alert anytime there are 3+ occurrences of the same string (even in the same cycle), it cannot be achieved with this configuration ... it would require new option for the content test (some counter test for the given pattern).
>
> Regards,
> Martin
>
>
>> On 20 Oct 2014, at 15:11, Ben Soot <[hidden email]> wrote:
>>
>> Hello,
>>
>> What is the best way to get alerts of repeated file content matches?
>>
>> I have 2 rules one for the same file so i can then distinguish in mmonit the service to send alerts to different mail addresses.
>>
>> Somehow the alerts for the repeated rule are not triggered... Anybody done sth like this?
>> also i never got the service group
>>
>> Im using monit 5.4 and mmonit 3.1.2
>>
>>
>> thanks Ben
>>
>>
>> set daemon  120
>> ...
>>
>>
>> check file foo.log  with path /home/foo.log
>>
>>     if match
>>           "^.*ACTION_REQUIRED.*$" then alert
>>
>> check file foo_REPEATED.log  with path /home/foo.log
>>     group repeatedfailure
>>     if match
>>           "^.*ACTION_REQUIRED.*$" within 3 cycles then alert
>>
>>
>>
>> --
>> To unsubscribe:
>> https://lists.nongnu.org/mailman/listinfo/monit-general
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

mmrobins
In reply to this post by martinp@tildeslash.com
On 14 Oct 2014, at 13:46, Alainkr <[hidden email]> wrote:
We have added the CLI wait and result report feature to our TODO list, currently the CLI just schedules the action and returns immediately.

I would love to see this feature as well.  

Besides the +1, I'll add a little bit of why.  We use monit in our deploy process in quite a few places to trigger restarts when new code goes out, but because this happens asynchronously it's hard to tell if the deploy succeeded until awhile after monit executes the restart command.  We tried having our deploys execute the commands directly so that we get can get this synchronously with a useful exit code, but what kept happening was someone would adjust the deploy restart command and forget to adjust the monit config with the new command or vice versa.

Another option would be to just have monit respond with what it would run, that way we could exec that, but that gets a little trickier for groups of things.  For example something like

# monit -g mygroup restart all
/usr/bin service1 restart
/usr/bin service2 restart
Reply | Threaded
Open this post in threaded view
|

Re: monit start/stop in a synchronous mode

martinp@tildeslash.com
Thanks for feedback, yes, we plan to implement the CLI wait.

Regards,
Martin



> On 16 Mar 2015, at 23:23, mmrobins <[hidden email]> wrote:
>
> On 14 Oct 2014, at 13:46, Alainkr &lt;akreienbuhl@&gt; wrote:
> We have added the CLI wait and result report feature to our TODO list,
> currently the CLI just schedules the action and returns immediately.
>
> I would love to see this feature as well.  
>
> Besides the +1, I'll add a little bit of why.  We use monit in our deploy
> process in quite a few places to trigger restarts when new code goes out,
> but because this happens asynchronously it's hard to tell if the deploy
> succeeded until awhile after monit executes the restart command.  We tried
> having our deploys execute the commands directly so that we get can get this
> synchronously with a useful exit code, but what kept happening was someone
> would adjust the deploy restart command and forget to adjust the monit
> config with the new command or vice versa.
>
> Another option would be to just have monit respond with what it would run,
> that way we could exec that, but that gets a little trickier for groups of
> things.  For example something like
>
> # monit -g mygroup restart all
> /usr/bin service1 restart
> /usr/bin service2 restart
>
>
>
> --
> View this message in context: http://nongnu.13855.n7.nabble.com/monit-start-stop-in-a-synchronous-mode-tp190714p197671.html
> Sent from the monit-general mailing list archive at Nabble.com.
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


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