Hi, all.
Anyone know how to generate a checksum on a directory that will change
if any contents of that directory, including subdirectories, changes?
I would like to write a script that monitors activity in a directory
and provide output if there's no activity in a certain amount of time
(~5 min). The best way I can think to do that is with checksums. If
the sum of the parent directory change after 5 minutes, generate the
output.
Thanks in advance.
|
|
0
|
|
|
|
Reply
|
bozothedeathmachine16 (49)
|
4/27/2011 2:00:29 PM |
|
In comp.unix.solaris bozothedeathmachine <bozothedeathmachine@gmail.com> wrote:
> Anyone know how to generate a checksum on a directory that will change
> if any contents of that directory, including subdirectories, changes?
Easiest thing to do would be to tar the directory into stdout, piped into
sum. This will catch even little stuff like a timestamp changing. However,
this isn't a good idea if there's a lot of data in that directory. Nor does
it tell you what changed, only that a change happened.
cd ${WATCHED_DIR}
NSUM=`tar cf - . | sum`
if [ "${NSUM}" != "${OSUM} ]
then
send_alert.sh
OSUM=${NSUM}
fi
Something more efficient would make use of find, iterating down the
tree and summing each file and building a table to compare against. You
could write such a thing in perl.
--
Brandon Hume - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
|
|
0
|
|
|
|
Reply
|
hume.spamfilter (184)
|
4/27/2011 2:10:59 PM
|
|
bozothedeathmachine <bozothedeathmachine@gmail.com> writes:
>Anyone know how to generate a checksum on a directory that will change
>if any contents of that directory, including subdirectories, changes?
>I would like to write a script that monitors activity in a directory
>and provide output if there's no activity in a certain amount of time
>(~5 min). The best way I can think to do that is with checksums. If
>the sum of the parent directory change after 5 minutes, generate the
>output.
Stat the directory; if it changes, then the stat return will change too.
(If you're interested in changes to the files, then you also need
to stat all the files; the information about those files are not
recorded in the directory)
Casper
--
|
|
0
|
|
|
|
Reply
|
Casper.Dik2 (258)
|
4/27/2011 2:14:10 PM
|
|
On Apr 27, 4:10=A0pm, hume.spamfil...@bofh.ca wrote:
> In comp.unix.solaris bozothedeathmachine <bozothedeathmach...@gmail.com> =
wrote:
>
> > Anyone know how to generate a checksum on a directory that will change
> > if any contents of that directory, including subdirectories, changes?
>
> Easiest thing to do would be to tar the directory into stdout, piped into
> sum. =A0This will catch even little stuff like a timestamp changing. =A0H=
owever,
> this isn't a good idea if there's a lot of data in that directory. =A0Nor=
does
> it tell you what changed, only that a change happened.
>
> cd ${WATCHED_DIR}
> NSUM=3D`tar cf - . | sum`
>
> if [ "${NSUM}" !=3D "${OSUM} ]
> then
> =A0 =A0 =A0 =A0 send_alert.sh
> =A0 =A0 =A0 =A0 OSUM=3D${NSUM}
> fi
>
> Something more efficient would make use of find, iterating down the
> tree and summing each file and building a table to compare against. =A0Yo=
u
> could write such a thing in perl.
>
> --
> Brandon Hume =A0 =A0- hume -> BOFH.Ca,http://WWW.BOFH.Ca/
Thanks, but that really won't work for me. We're looking at a parent
directory with 8TB+ and want to monitor on an interval of ~5 min.
I was also thinking about summing the sums of the files. I'll keep
that in mind.
Thanks
|
|
0
|
|
|
|
Reply
|
bozothedeathmachine16 (49)
|
4/27/2011 3:45:40 PM
|
|
On Apr 27, 4:14=A0pm, Casper H.S. Dik <Casper....@OrSPaMcle.COM> wrote:
> bozothedeathmachine <bozothedeathmach...@gmail.com> writes:
> >Anyone know how to generate a checksum on a directory that will change
> >if any contents of that directory, including subdirectories, changes?
> >I would like to write a script that monitors activity in a directory
> >and provide output if there's no activity in a certain amount of time
> >(~5 min). The best way I can think to do that is with checksums. If
> >the sum of the parent directory change after 5 minutes, generate the
> >output.
>
> Stat the directory; if it changes, then the stat return will change too.
> (If you're interested in changes to the files, then you also need
> to stat all the files; the information about those files are not
> recorded in the directory)
>
> Casper
> --
I checked out the man page. That's a pretty cool function. Is there
anyway to use it as a system call/command though? It seems a bit much
to write a C program just to get the info.
Thanks!
|
|
0
|
|
|
|
Reply
|
bozothedeathmachine16 (49)
|
4/27/2011 3:48:25 PM
|
|
bozothedeathmachine <bozothedeathmachine@gmail.com> writes:
>On Apr 27, 4:14=A0pm, Casper H.S. Dik <Casper....@OrSPaMcle.COM> wrote:
>> bozothedeathmachine <bozothedeathmach...@gmail.com> writes:
>> >Anyone know how to generate a checksum on a directory that will change
>> >if any contents of that directory, including subdirectories, changes?
>> >I would like to write a script that monitors activity in a directory
>> >and provide output if there's no activity in a certain amount of time
>> >(~5 min). The best way I can think to do that is with checksums. If
>> >the sum of the parent directory change after 5 minutes, generate the
>> >output.
>>
>> Stat the directory; if it changes, then the stat return will change too.
>> (If you're interested in changes to the files, then you also need
>> to stat all the files; the information about those files are not
>> recorded in the directory)
>>
>> Casper
>> --
>I checked out the man page. That's a pretty cool function. Is there
>anyway to use it as a system call/command though? It seems a bit much
>to write a C program just to get the info.
Newer versions of Solaris have the "stat" command but what you could do
is something simple like creating a file:
touch -r /your/directory /tmp/timetamp
(copies the time stamp of your directory to the file /tmp/timestamp)
and then use find to see if it was changed:
find /your/directory -prune -newer /tmp/timestamp
and either it prints nothing (nothing has changed) or it will print
the name of your directory (something has changed)
When that happens you run the touch command and whetever you want to
do with the directory.
Casper
--
|
|
0
|
|
|
|
Reply
|
Casper.Dik2 (258)
|
4/27/2011 6:22:30 PM
|
|
On 4/27/2011 2:22 PM, Casper H.S. Dik wrote:
> bozothedeathmachine <bozothedeathmachine@gmail.com> writes:
>
>> On Apr 27, 4:14=A0pm, Casper H.S. Dik <Casper....@OrSPaMcle.COM> wrote:
>>> bozothedeathmachine <bozothedeathmach...@gmail.com> writes:
>>>> Anyone know how to generate a checksum on a directory that will change
>>>> if any contents of that directory, including subdirectories, changes?
>>>> I would like to write a script that monitors activity in a directory
>>>> and provide output if there's no activity in a certain amount of time
>>>> (~5 min). The best way I can think to do that is with checksums. If
>>>> the sum of the parent directory change after 5 minutes, generate the
>>>> output.
>>>
>>> Stat the directory; if it changes, then the stat return will change too.
>>> (If you're interested in changes to the files, then you also need
>>> to stat all the files; the information about those files are not
>>> recorded in the directory)
>>>
>>> Casper
>>> --
>
>> I checked out the man page. That's a pretty cool function. Is there
>> anyway to use it as a system call/command though? It seems a bit much
>> to write a C program just to get the info.
>
> Newer versions of Solaris have the "stat" command but what you could do
> is something simple like creating a file:
>
> touch -r /your/directory /tmp/timetamp
>
> (copies the time stamp of your directory to the file /tmp/timestamp)
> and then use find to see if it was changed:
>
> find /your/directory -prune -newer /tmp/timestamp
>
> and either it prints nothing (nothing has changed) or it will print
> the name of your directory (something has changed)
>
> When that happens you run the touch command and whetever you want to
> do with the directory.
>
> Casper
I seem to remember there is something called a "File Alteration Monitor"
(or maybe "file Integrity Monitor") available. Maybe CSWfam?
--
Wayne
|
|
0
|
|
|
|
Reply
|
nospam66 (816)
|
4/27/2011 6:45:45 PM
|
|
On 04/28/11 02:00 AM, bozothedeathmachine wrote:
> Hi, all.
>
> Anyone know how to generate a checksum on a directory that will change
> if any contents of that directory, including subdirectories, changes?
>
> I would like to write a script that monitors activity in a directory
> and provide output if there's no activity in a certain amount of time
> (~5 min). The best way I can think to do that is with checksums. If
> the sum of the parent directory change after 5 minutes, generate the
> output.
If you are running a recent OpenSolaris build (including 11 Express),
you could uses frequent snapshots and zfs diff.
--
Ian Collins
|
|
0
|
|
|
|
Reply
|
ian-news (9881)
|
4/27/2011 8:09:43 PM
|
|
|
7 Replies
105 Views
(page loaded in 0.345 seconds)
Similiar Articles: Calculation and verification of IBAN checksums - comp.lang.awk ...print " (Skipping this IBAN...)" next } substr($0,3,2) == "00" { # generate checksum print "98 - ( " iban " % 97 )" |& "bc ... Accessing file while it is being copied - comp.lang.java ...Possible solutions: A) make a second directory for links to files D) create a sentinel file for ... You might try reading it again and again until it's checksum ... Ping from C tutorial, problem - comp.compilers.lccThe pseudo checksum has to be computed for IPv6 ... Description: // Setup the ICMP raw socket and create ... was not found when searching DLL's in the system directory ... Making a depot compatible with Apache 2.0 and 2.2 - comp.sys.hp ...With this change, the directory for Apache moved from ... of all files to be installed with their size, checksum ... the installer from a real HP-UX script, I could create ... How to EXPLODE using freeware libs - comp.compression:-) What I tried also is to create a fake zip file (by ... compression option creating test.zip. AFAIK the checksum ... can use blast found in > the zlib beta contrib directory ... Compare contents of Zip files for changes. - comp.unix.solaris ...Checksum with no creation date - comp.lang.java.help Compare contents of Zip files for changes. - comp.unix.solaris ... Checksum with no creation date - comp.lang.java ... getting cpan configured - comp.unix.shellERROR: Can't create '/usr/local/man/man3' mkdir /usr ... to look at the files in my /usr/share/man directory and ... 37.tar.gz CPAN: Digest::SHA loaded ok (v5.47) Checksum ... root CA certificates for wget/openssl - comp.unix.solaris ...With either installation DVDs or checksum of downloaded ... not requiring any payment, one could easily create an ... certificate in /etc/pki/tls/certs or equivalent directory ... Making programs more Vista/7 compatible - comp.os.ms-windows ...Both programs are run in their own directory, often not ... You could create a manifest for your app as Leslie ... sys.hp ..... to be installed with their size, checksum ... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... checksum for Windows.. SHA1 or MD5 hash a file, a folder, or a ...checksum is a no-nonsense SHA1/MD5 hashing tool for Windows. A program to create and verify checksums of a file, a folder/directory, or an entire hard drive or disk ... Unix + Linux ---> checksum for a directoryHow to generate checksum for an entire directory in Unix. Any command or script?? Thnx 7/25/2012 2:02:52 AM
|