Send status notifications

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

Send status notifications

Lutz Mader
Hello Tildeslash,
I try to send status notifications to a central system, this works well
all the time an application stopped by an failure or get some problems.

But all the time I use "monit stop" to stop an application I got no
notification, the script will not called by Monit.

I used the following process definition in my test environment (with
monit 5.25.1 and monit 5.21.0).

check process wait.sh matching "sleep"
  start program = "/Users/lutz/Aufheben/monit/scripts/wait.sh"
  stop program = "/Users/lutz/Aufheben/monit/scripts/wait.sh"
  restart program = "/Users/lutz/Aufheben/monit/scripts/wait.sh"
  if cpu usage > 55% for 10 cycles then stop
  if not exist then restart
  if not exist then exec "/Users/lutz/Aufheben/monit/scripts/zexec.sh"
    else if succeeded then exec
"/Users/lutz/Aufheben/monit/scripts/zexec.sh"

The script "zexec.sh" is the notification script I used to send
information to a central system (the central system send SMS or mail
notifications).

 wait.sh                         │ Does not exist             │ Process
:
[CEST Jun 16 11:05:34] error    : 'wait.sh' process is not running
[CEST Jun 16 11:05:34] info     : 'wait.sh' exec:
'/Users/lutz/Aufheben/monit/scripts/zexec.sh'
[CEST Jun 16 11:05:34] error    : 'wait.sh' process is not running
[CEST Jun 16 11:05:34] info     : 'wait.sh' trying to restart
[CEST Jun 16 11:05:34] info     : 'wait.sh' restart:
'/Users/lutz/Aufheben/monit/scripts/wait.sh'
:
[CEST Jun 16 11:06:36] info     : 'wait.sh' process is running with pid
14501
[CEST Jun 16 11:06:36] info     : 'wait.sh' exec:
'/Users/lutz/Aufheben/monit/scripts/zexec.sh'
[CEST Jun 16 11:06:36] info     : 'wait.sh' process is running with pid
14501
:
 wait.sh                         │ OK                         │ Process

All the time a problem was recovery by Monit the notification script was
called.

 wait.sh                         │ OK                         │ Process
 monit stop wait.sh
 :
[CEST Jun 16 11:06:59] info     : 'wait.sh' stop on user request
[CEST Jun 16 11:07:06] info     : 'wait.sh' stop:
'/Users/lutz/Aufheben/monit/scripts/wait.sh'
[CEST Jun 16 11:07:37] error    : 'wait.sh' failed to stop (exit status
0) -- no output
[CEST Jun 16 11:07:37] info     : 'wait.sh' stop action failed
:
 wait.sh                         │ Not monitored              │ Process
 monit start wait.sh
:
[CEST Jun 16 11:08:32] info     : 'wait.sh' start on user request
[CEST Jun 16 11:08:32] info     : 'wait.sh' start:
'/Users/lutz/Aufheben/monit/scripts/wait.sh'
[CEST Jun 16 11:08:32] info     : 'wait.sh' start action done
:
 wait.sh                         │ OK                         │ Process

But all the time I restart the application via Monit, the notification
script was not called.

I try to use someting like this as well.

if changed pid then exec exec "/Users/lutz/Aufheben/monit/scripts/zexec.sh"

But get a notification on pid changes only, if the pid disappear, no
notifications send.

Any idea how to get a status notification all the time, send by Monit
itself (or via M/Monit).

Thanks for any suggestion,
Lutz

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

Re: Send status notifications

martinp@tildeslash.com
Hello Lutz,

the CLI start/stop/restart/monitor/unmonitor action event is called "action" (stands for "user action") ... there is no rule in your configuration file for this event type which would trigger the script.  The rules in your configuration file will catch just anomalies (process stopped/died whereas it should be running). The notification should be send even with manual action, provided you didn't filter out the "action" event.


Best regards,
Martin


> On 16 Jun 2018, at 12:41, Lutz Mader <[hidden email]> wrote:
>
> Hello Tildeslash,
> I try to send status notifications to a central system, this works well
> all the time an application stopped by an failure or get some problems.
>
> But all the time I use "monit stop" to stop an application I got no
> notification, the script will not called by Monit.
>
> I used the following process definition in my test environment (with
> monit 5.25.1 and monit 5.21.0).
>
> check process wait.sh matching "sleep"
>  start program = "/Users/lutz/Aufheben/monit/scripts/wait.sh"
>  stop program = "/Users/lutz/Aufheben/monit/scripts/wait.sh"
>  restart program = "/Users/lutz/Aufheben/monit/scripts/wait.sh"
>  if cpu usage > 55% for 10 cycles then stop
>  if not exist then restart
>  if not exist then exec "/Users/lutz/Aufheben/monit/scripts/zexec.sh"
>    else if succeeded then exec
> "/Users/lutz/Aufheben/monit/scripts/zexec.sh"
>
> The script "zexec.sh" is the notification script I used to send
> information to a central system (the central system send SMS or mail
> notifications).
>
> wait.sh                         │ Does not exist             │ Process
> :
> [CEST Jun 16 11:05:34] error    : 'wait.sh' process is not running
> [CEST Jun 16 11:05:34] info     : 'wait.sh' exec:
> '/Users/lutz/Aufheben/monit/scripts/zexec.sh'
> [CEST Jun 16 11:05:34] error    : 'wait.sh' process is not running
> [CEST Jun 16 11:05:34] info     : 'wait.sh' trying to restart
> [CEST Jun 16 11:05:34] info     : 'wait.sh' restart:
> '/Users/lutz/Aufheben/monit/scripts/wait.sh'
> :
> [CEST Jun 16 11:06:36] info     : 'wait.sh' process is running with pid
> 14501
> [CEST Jun 16 11:06:36] info     : 'wait.sh' exec:
> '/Users/lutz/Aufheben/monit/scripts/zexec.sh'
> [CEST Jun 16 11:06:36] info     : 'wait.sh' process is running with pid
> 14501
> :
> wait.sh                         │ OK                         │ Process
>
> All the time a problem was recovery by Monit the notification script was
> called.
>
> wait.sh                         │ OK                         │ Process
> monit stop wait.sh
> :
> [CEST Jun 16 11:06:59] info     : 'wait.sh' stop on user request
> [CEST Jun 16 11:07:06] info     : 'wait.sh' stop:
> '/Users/lutz/Aufheben/monit/scripts/wait.sh'
> [CEST Jun 16 11:07:37] error    : 'wait.sh' failed to stop (exit status
> 0) -- no output
> [CEST Jun 16 11:07:37] info     : 'wait.sh' stop action failed
> :
> wait.sh                         │ Not monitored              │ Process
> monit start wait.sh
> :
> [CEST Jun 16 11:08:32] info     : 'wait.sh' start on user request
> [CEST Jun 16 11:08:32] info     : 'wait.sh' start:
> '/Users/lutz/Aufheben/monit/scripts/wait.sh'
> [CEST Jun 16 11:08:32] info     : 'wait.sh' start action done
> :
> wait.sh                         │ OK                         │ Process
>
> But all the time I restart the application via Monit, the notification
> script was not called.
>
> I try to use someting like this as well.
>
> if changed pid then exec exec "/Users/lutz/Aufheben/monit/scripts/zexec.sh"
>
> But get a notification on pid changes only, if the pid disappear, no
> notifications send.
>
> Any idea how to get a status notification all the time, send by Monit
> itself (or via M/Monit).
>
> Thanks for any suggestion,
> Lutz
>
> --
> 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: Send status notifications

Lutz Mader
Hello Martin,
the used rules are for problems/anomalies only.
I am not aware of the capability to define rules for actions as well.
I thought the action event is form Monit internal use only.

How to override the action handling to add a script.

With regards,
Lutz

> Hello Lutz,
>
> the CLI start/stop/restart/monitor/unmonitor action event is called "action" (stands for "user action") ... there is no rule in your configuration file for this event type which would trigger the script.  The rules in your configuration file will catch just anomalies (process stopped/died whereas it should be running). The notification should be send even with manual action, provided you didn't filter out the "action" event.
>
>
> Best regards,
> Martin


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

Re: Send status notifications

Lutz Mader
In reply to this post by martinp@tildeslash.com
Hello Martin,
I sent some time to have a look to the Monit wiki and the only way I
find to send "action" notifications (or not) is the "alert" rule.

set alert [hidden email] on { instance, action }

> The notification should be send even with manual action, provided you didn't filter out the "action" event.

This is the only place I find a rule to handle "action" (and "instance")
with Monit. The parser control file p.y contain a rule to use "action"
with the "alert" or "set alert" statement only.

With regards,
Lutz

p.s.
It seems to me, "Event_Action" (and "Event_Instance") is used by Monit
(and M/Monit) only, it is for internal use only.


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