monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple 'every' clauses not working as expected


From: Lutz Mader
Subject: Re: Multiple 'every' clauses not working as expected
Date: Tue, 5 Jan 2021 14:01:44 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Hello Aaron,
based on your ticket/issue sample, this looks similar to the my test case.

check program test-program path /Users/lutz/monit/scripts/test.sh
  timeout 10 seconds
  every 20 cycles
  depends on test-file
  if status !=0 then exec "/Users/lutz/monit/scripts/env.sh"
    else if succeeded then exec "/Users/lutz/monit/scripts/env.sh"

check file test-file path /Users/lutz/monit/test
  not every "* 0-6,22-23 * * *"
  if timestamp is older than 1 day then alert

If you start monit with option "-v" (and "-I") you will see something
like this in the monit log file (and the terminal).

The "test" file is not available and the "test-program can not started
therefore.

'test-file' file doesn't exist
'test-file' trying to restart
'test-program' stop skipped -- method not defined
'test-file' stop skipped -- method not defined
'test-file' start method not defined
'test-file' monitoring enabled
'test-file' start method not defined
'test-file' monitoring enabled
'test-file' file doesn't exist
'test-program' failed to start -- could not start required services:
'test-file'
'test-program' test skipped as required service 'test-file' has errors
:
'test-file' file doesn't exist
'test-file' trying to restart
'test-program' stop skipped -- method not defined
'test-file' stop skipped -- method not defined
'test-file' start method not defined
'test-file' monitoring enabled
'test-file' start method not defined
'test-file' monitoring enabled
'test-file' file doesn't exist
'test-program' failed to start -- could not start required services:
'test-file'
'test-program' test skipped as current cycle (1) < every cycle (20)

You will see the cycle count you used with "every" for "test-program".
As long this counter is not "20" the program will not start.

'test-file' file exists
'test-file' is a regular file
'test-file' modify/change time test succeeded for /Users/lutz/monit/test
[current modify/change time is Tue, 05 Jan 2021 12:18:03]
'test-program' status succeeded (0) -- Test Di 5 Jan 2021 12:28:38 CET
'test-program' test skipped as current cycle (1) < every cycle (20)

But after a while, the counter will be reached and the script will be
executed and the status will used by monit.

You should wait for 20 cycles (or less) until to get the status.
The first cycle start with the monit start or reload, but not at the
first time the "test-file" became available.

I think the answer fits to that, what you see.
With regards,
Lutz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]