Hi,
I've noticed that when I'm monitoring large files for changes that are being
rewritten, FAM generates a lot of FAMChanged events. And rightly so.
My question is this:
Can my FAM Client software operate on the assumption that I'll get all of
these FAMChanged Events in one shot? (Eg in a FAMPending loop.)
Another way of putting it is like this: Is the FAM server a fast writer to
my FAM Client's slow reader?
I sent mail to owner-fam@xxxxxxxxxxx yesterday, and I'm not sure if this is
the same address or not, so I'l repeat my earlier email and expand on it:
I'm writing a fileschanged command line utility that uses Fam. It works
like this: You give it a list of files and it returns the filenames of
altered files as they change.
I've got it working with autoconf and I'm done except for a few issues.
They are:
1) large files get a lot of FAMChanged Events. (explained above)
2) I'm using realpath, so symlinks are resolved, it may cause the recursive
option to run infinitely. (I can add code to detect this)
3) I'm assuming the device id and inode of a monitored file or directory is
unique. I think nfs breaks this assumption, but I may be wrong. (no clue)
The fileschanged utility will be useful in shell scripts. Take this one for
example: It takes all outgoing mail and saves it to a tar file.
---
#!/bin/bash
fileschanged --files-to-monitor /var/spool/mqueue | while read file
; do
tar -uPvf /tmp/outgoingmail.tar $file
done
---
Simple eh?
It can also be used in this manner:
---
#!/bin/fileschanged --recursive
/home/myuser
/var/log/messages
/var/log/httpd/access_log
---
And the script will report when files have been changed.
Nifty eh?
And the default way to use fileschanged is like this:
% fileschanged --recursive filelist
where filelist is a file that looks like:
---
/home/myuser
/var/log/messages
/var/log/httpd/access_log
---
fileschanged has code in it that prevents the same file from being monitored
twice.
% fileschanged --recursive --files-to-monitor /var/log /var/log/messages
or
% fileschanged --recursive --files-to-monitor /var/log/messages /var/log
both run such that /var/log/messages appears on the stdout only once when
it's changed.
fileschanged would be very simple if it didn`t check to see if a file is
already being monitored.
Here's the current --help screen. maybe it will make more sense than my
examples.
Usage: fileschanged [OPTION...] [FILE]...
Show altered files from the list of filenames given in FILE. The standard
input can be used if FILE is - or absent.
-d, --show-deleted Also show deleted or moved files to stderr
-f, --files-to-monitor Monitor the list of files on the command line
-h, --hash-is-not-comment Don't ignore lines in FILE starting with '#'
-l, --filelist (Default) Monitor the list of filenames in FILE
-r, --recursive Monitor subdirectories of directories
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Report bugs to <bda@xxxxxxxxx>.
And that's it.
I still need to make the info and man pages, and make an rpm but I'm just
about finished. I hope I haven't recreated somebody else's wheel!
Please let me know what you think about fileschanged. I can send you the
code if you like -- I don't have a clue if it will work on Irix.
Please respond to ``benasselstine (at) sympatico (dot) ca`` instead of the
return address on this message.
thx.
Ben
--
Source code, list archive, and docs: http://oss.sgi.com/projects/fam/
To unsubscribe: echo unsubscribe fam | mail majordomo@xxxxxxxxxxx
|