alert on file not changed

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

alert on file not changed

Nick Upson-2
Hi

I'm trying to detect that a program has stopped writing to its logfile but have been unable to come up with a working monit config to do so, has someone already done this and willing to share?

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

Re: alert on file not changed

admin@extremeshok.com

Create a small bash script with the follow, this should give a true/false value (1/0) for $filename older than 30 minutes:

echo $(( (`date +%s` - `stat -L --format %Y $filename`) > (30*60) ))

_________________ eXtremeSHOK.com _________________

On 12 Jul 2017, at 10:14 AM, Nick Upson <[hidden email]> wrote:

Hi

I'm trying to detect that a program has stopped writing to its logfile but have been unable to come up with a working monit config to do so, has someone already done this and willing to share?

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

Re: alert on file not changed

Lutz Mader
In reply to this post by Nick Upson-2
Hello Nick,

> I'm trying to detect that a program has stopped writing to its logfile but
> have been unable to come up with a working monit config to do so, has
> someone already done this and willing to share?

If you use Monit >= 5.22.0, you can define a check like this.

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.

With regards,
Lutz


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