[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Check file and match behavior
From: |
address@hidden |
Subject: |
Re: Check file and match behavior |
Date: |
Tue, 11 Jul 2017 11:07:14 +0200 |
Hi Lutz,
if your application log is set to a standalone file, you can test a
modification timestamp if it logs some messages while it is running. For
example (syntax for Monit >= 5.22.0):
check file myapp_log with path /var/log/myapp.log
if timestamp is older than 1 hour then exec "/usr/bin/monit
restart myapp"
The test will restart "myapp" service if the timestamp was not modified within
last hour.
You can see more details in monit manual:
https://mmonit.com/monit/documentation/monit.html#TIMESTAMP-TEST
Best regards,
Martin
> On 10 Jul 2017, at 14:08, Lutz Mader <address@hidden> wrote:
>
> Hi all folks,
> a question of understanding.
>
> One of my applications hangs sometimes after the start.
> But the only hint that something is going wrong, the application does
> not continue to start, is the last message in the application log on the
> one hand. It's always the same message, I think.
> And on the other, that no additional messages are written to the log.
>
> Unfortunately, if everything works well, all the messages are written to
> the log and some more messages also.
> And it is normal behaviour that the application stop writing messages to
> the log after the start, for a short time, sometimes.
>
> My question,
> any suggestion how to check a message is the last one in the log for a
> given time. In my understanding, monit doesn't check a message already
> checked again, monit knows the last line in the log already checked.
>
> A suggestion,
> any plan to set the service status based on messages.
> Today I use the port to check the application is up and running or
> restart the application if the port is not available.
> I use something like this.
> if failed host TheHostName port 5001 protocol http for 10 cycles then alert
> if failed host TheHostName port 8080 protocol http for 20 cycles then
> restart
>
> Some of my application doesn't open a socket, I can't check a port also.
> But the log contain messages like "manager initialized" or "manager
> started".
>
> Today I use commands to restart applications or disable the monitoring
> for applications based on messages are written to the application log or
> send mails.
> I use something like this.
> if match ".*Too many open files.*" then exec "/etc/monit/scripts/em.sh
> restart"
> if match ".*An attempt is made to stop the.*" then exec
> "/etc/monit/scripts/serv.sh unmonitor server1"
> if match "Press 'Enter' to acknowledge...." then alert
>
> But I don't know a command to set the service status.
> "monitor" or "unmonitor" enable/disable the monitoring only.
>
> With regards,
> Lutz
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general