[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Get monit exit status from the command line
From: |
Rui Lapa |
Subject: |
Re: Get monit exit status from the command line |
Date: |
Wed, 11 May 2016 00:09:31 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 |
1. Using check program
( https://mmonit.com/monit/changes/)
A new environment variable MONIT_PROGRAM_STATUS was added to check
program to allow scripts called from exec to access the check programs
last exit status.
check program test with path "test.sh blabla" as uid "monkey"
if status != 0 then exec "error.sh" [repeat every [x] cycle(s)]
if status = 0 then exec "all_ok.sh" [repeat every [x] cycle(s)]
Check ENV on error.sh exec script! ;)
On exec you can even set a file with the error and check that file
exists and/or has content.
PS: Don't know if "monkey" uid is respected though ;)
2. Why not use Monit HTTP API
format can be:
- text (default)
- xml (global status only)
All services check:
http://address@hidden:2812/_status?format=xml
Service check:
http://address@hidden:2812/_status?service=sshd (No XML format)
If API supported json support you could use jq... to filter/extract content.
My 10 cents,
Rui Lapa
On 05/10/2016 01:30 PM, Dominic Harkness wrote:
Hi all,
My team is interested in a feature that would allow a script to call
some command from the CLI that would test the last exit status for one,
some, or all of the monitored services. The response would be a Boolean
that would tell you “All tests passed” or “Not all tests passed.”
“monit status/summary” gives you a text representation of this data, but
a script would have to parse the text output to determine if all of the
tests passed. “monit validate” gives you its exit status, but you have
to actually run monit. We feel it would be useful to ask monit if some
test(s) passed from within a script and get a true or false response
without running validate().
Please let me know what you think of this and if you have any
suggestions. I would like to get started on this feature as soon as
possible.
Thanks
Dominic Harkness
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general