monit-general
[Top][All Lists]
Advanced

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

Re: Monitoring directory/filesystem write activity


From: Are Gravbrøt
Subject: Re: Monitoring directory/filesystem write activity
Date: Thu, 31 Mar 2011 08:41:26 +0200

Hi!

-Thanks for your quick response!

Still haven't found a satisfactory solution though... It appears that checksum only applies to files, not directories.  Furthermore regarding timestamp, in my case new files are seldomly created (only each hour maybe). This makes it sub-optimal to monitor the timestamp on the directory (only changed when a new file is added).

So, what I have done so far is to write a small script that checks for size  changes in the most recently written file found in the directory. Then, by comparing the current size with the previous result from the same script, I am able to find out if there has been any data written. The script basically looks like this:

PREV_SIZE=$(cat $SIZE_FILE)

ls -st $DATA_DIR|head -n 2|tail -n 1 > $SIZE_FILE

if [ "$(cat $SIZE_FILE)" != "$PREV_SIZE" ]; then
 echo 1 > $STATUS_FILE
else
 echo 0 > $STATUS_FILE
fi

I run this script in a loop each 5 second, keeping the contents of $STATUS_FILE updated. I configure monit to watch the status file and my process like this:

check process myproc with pidfile /var/run/myproc.pid
 start program = "/etc/init.d/myproc start"
 stop program = "/etc/init.d/myproc stop"
 if 10 restarts within 30 cycles then timeout
 depends on statusfile

check file statusfile path /data/statusfile
 if failed checksum and expect the sum b026324c6904b2a9cb4b88d6d61c81d1 then restart #Checks that contents of status file is 1
 if timestamp > 10 second then alert #Checks if the extra script loop has actually run


The drawback of this solution is that I need to run the extra status script in a separate loop (I cannot run it under cron, since I need it to run more often than monits cycle time, which I have configured to 10 seconds)

Could this be done in a more elegant way?

Kind Regards,

Are

On Wed, Mar 30, 2011 at 9:04 AM, Pablo Iranzo Gómez <address@hidden> wrote:



De: "Pablo Iranzo Gómez" <address@hidden>
Para: "This is the general mailing list for monit" <address@hidden>
Enviados: Miércoles, 30 de Marzo 2011 9:03:37
Asunto: Re: Monitoring directory/filesystem write activity



Hi


De: "Are Gravbrøt" <address@hidden>
Para: address@hidden
Enviados: Miércoles, 30 de Marzo 2011 8:52:45
Asunto: Monitoring directory/filesystem write activity

Hi!

I have an application that is supposed to continuously write data files to a directory, say /data.

Is there any possibility in monit to easily check that data has actually been written to one or more files under /data since the last cycle?

I think that a checksum over the directory would help. I used a similar setup to have a monit monitor a secondary monit and restart if if there were new rules created for it (for allowing users to create new rules and have them automatically monitored).

s/checksum/timestamp/ :-)





Regards
Pablo

--

Pablo Iranzo Gómez (address@hidden)
Senior Global Profesional Services Consultant (RHCA, RHCSS, RHCDS, RHCVA, RHCE, RHCSP) #804006196923216
Phone: +34 645 01 01 49 (CET/CEST)
GnuPG KeyID: 0xFAD3CF0D


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



--

Pablo Iranzo Gómez (address@hidden)
Senior Global Profesional Services Consultant (RHCA, RHCSS, RHCDS, RHCVA, RHCE, RHCSP) #804006196923216
Phone: +34 645 01 01 49 (CET/CEST)
GnuPG KeyID: 0xFAD3CF0D


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


reply via email to

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