monit-general
[Top][All Lists]
Advanced

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

Re: Alert if file contents are greater than 40


From: Michael Johnson - MJ
Subject: Re: Alert if file contents are greater than 40
Date: Fri, 11 Jan 2013 04:35:26 -0800

I think you are trying to accomplish something that monit simply was not intended to do, that being said, here is a work around that will absolutely work given the documentation

* Modify your script slightly to to initially write out the new data into /path/to/file.new

* Once the file is written, have your script move the file to /path/to/file (the intended location.

This will have the side effect of ensuring the inode is updated each time new data is available and thus monit will reread the file.  Additionally, this also will ensure that the full contents of the file are in place before monit reads the file because a move is an atomic operation.  This may not be of concern to you nor terribly important for this particular task, but it is worth noting as it can be very important.

Long term I would suggest you look at handlng this differently.  For short term, this will get you going and if you decide to keep it around, you may want to revisit the methodology in the future.


On Fri, Jan 11, 2013 at 3:41 AM, Jenny Hopkins <address@hidden> wrote:
On 11 January 2013 11:02, Callum Macdonald
<address@hidden> wrote:
> Did you read the line of the manual I quoted? I don't think the regex is
> your problem, I think you've  misunderstood how the file content check
> works. - C
>

I'm sure I have misunderstood!
Your quote is from here, I assume:
http://mmonit.com/monit/documentation/monit.html#file_content_testing
What I don't understand is that the node and file size can stay the
same even if the content is changing, so monit won't check. Unless my
script destroys then recreates the file each time it runs?

Ah well - no worries! Thanks for your replies.

Jenny


>
> On 11/01/13 17:18, Jenny Hopkins wrote:
>>
>> On 11 January 2013 03:54, Callum Macdonald
>> <address@hidden> wrote:
>>>
>>> Hi Jenny,
>>>
>>> Have you considered having monit measure the program's memory usage?
>>>
>>> I think this line of the manual may be relevant to your situation:
>>>
>>> On startup the read position is set to the end of the file and monit
>>> continue to scan to the end of file on each cycle. But if the file size
>>> should decrease or inode change the read position is set to the start of
>>> the
>>> file.
>>>
>>> As I understand it, monit will probably read the file once, then wait for
>>> new lines to be written. In your case, if the filesize remains the same
>>> or
>>> increases, monit will never again read the first (and only) line of the
>>> file.
>>>
>>> I think this feature is aimed at log file monitoring, when data is
>>> constantly being written to a continuous log file. If you were to write a
>>> new line to the file every 10 minutes and then truncate it every so
>>> often,
>>> that might work. But honestly, it all sounds far more complicated than
>>> letting monit measure your memory usage.
>>>
>>> Love & joy - Callum.
>>>
>>
>> I've got monit watching stock programs such as apache2 and
>> spamassassin, but this particular problem concerns not a global
>> program running (debian server) but an individual user's programs, if
>> that makes sense. Hence my script to pick out that particular user and
>> write to file.
>> It was more the syntax I was asking about for my regex.
>>
>> Thanks for the replies,
>> Jenny
>>
>> --
>> To unsubscribe:
>> https://lists.nongnu.org/mailman/listinfo/monit-general
>>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general

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



--
Michael Johnson - MJ

reply via email to

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