Notification script in check program

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

Notification script in check program

Lutz Mader
Hello Tildeslash,
I use "CHECK PROGRAM" to do some additional application checks.
Based on the return code and an appropriate "IF STATUS" rule I send
alert/mail notifications from Monit.

This works well in the past, but I try to use a script to send SMS
notifications now. I get the "Status failed" alerts, but the "Status
succeeded" can not send.

Any plan to make the a "IF SUCCEEDED THEN" available for the "CHECK
PROGRAM" in the future or any suggestion how to get a succeed notification.

With regards,
Lutz

p.s.
A status check with 0 doesn't work, because the service get the status
"Status failed" with that.

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

Re: Notification script in check program

martinp@tildeslash.com
Hi Lutz,

you can use multiple status tests within the 'check program' - if the status differs on program success, the second status check should catch it, something like this:

 check program myprogram with path "/usr/local/bin/helloworld"
       if status = 0 then exec "/usr/local/bin/script_no_1"
       if status > 0 then exec "/usr/local/bin/script_no_2"

Best regards,
Martin


> On 21 Jun 2018, at 23:24, Lutz Mader <[hidden email]> wrote:
>
> Hello Tildeslash,
> I use "CHECK PROGRAM" to do some additional application checks.
> Based on the return code and an appropriate "IF STATUS" rule I send
> alert/mail notifications from Monit.
>
> This works well in the past, but I try to use a script to send SMS
> notifications now. I get the "Status failed" alerts, but the "Status
> succeeded" can not send.
>
> Any plan to make the a "IF SUCCEEDED THEN" available for the "CHECK
> PROGRAM" in the future or any suggestion how to get a succeed notification.
>
> With regards,
> Lutz
>
> p.s.
> A status check with 0 doesn't work, because the service get the status
> "Status failed" with that.
>
> --
> 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: Notification script in check program

Lutz Mader
Hello Martin,
you are right, multiple status checks are useable.

>  check program myprogram with path "/usr/local/bin/helloworld"
>        if status = 0 then exec "/usr/local/bin/script_no_1"
>        if status > 0 then exec "/usr/local/bin/script_no_2"

The problem, all this checks are report with "Status failed". There is
no way to report a "Status succeeded" this way.

With regards,
Lutz


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

Re: Notification script in check program

Lutz Mader
In reply to this post by martinp@tildeslash.com
Hello Martin,
FYI, I fixed my "check program" notification problem by using multiple
status checks to do something and one check to notify the "status
failed" and "status succeeded" only.

check program script.sh with path
/Users/lutz/Aufheben/monit/scripts/script.sh
  if status = 1 then exec "/Users/lutz/Aufheben/monit/scripts/script1.sh"
  if status = 2 then exec "/Users/lutz/Aufheben/monit/scripts/script2.sh"
  if status != 0 then exec "/Users/lutz/Aufheben/monit/scripts/zexec.sh"
    else if succeeded then exec
"/Users/lutz/Aufheben/monit/scripts/zexec.sh"

> you can use multiple status tests within the 'check program' - if the status differs on program success, the second status check should catch it, something like this:
>
>  check program myprogram with path "/usr/local/bin/helloworld"
>        if status = 0 then exec "/usr/local/bin/script_no_1"
>        if status > 0 then exec "/usr/local/bin/script_no_2"

This way seems to work.
I get notifications and the scripts are called also.

With regards,
Lutz


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