Paul

Being a script hacker like you the only kludge I can think of.

A script that does something like

ls >
/tmp/foo
sleep
ls /tmp/foo.new
diff
/tmp/foo /tmp/foo.new > /tmp/files_that_have_changed
mv /tmp/foo.new /tmp/foo

Or you might be able to knock something up with bart nd zfs snapshots.
I did write this which may help?????

#!/bin/sh

#set -x

# Note: No implied warranty etc. applies.
#       Don't cry if it does not work. I'm an SE not a programmer!
#
###################################################################
#
# Version 29th Jan. 2009
#
#     GOAL: Show what files have changed between snapshots
#
#     But of course it could be any two directories!!
#
###################################################################
#

## Set some variables
#
SCRIPT_NAME=$0
FILESYSTEM=$1
SNAPSHOT=$2
FILESYSTEM_BART_FILE=/tmp/filesystem.$$
SNAPSHOT_BART_FILE=/tmp/snapshot.$$
CHANGED_FILES=/tmp/changes.$$


## Declare some commands (just in case PATH is wrong, like cron)
#
BART=/bin/bart


## Usage
#
Usage()
{
        echo ""
        echo ""
        echo "Usage: $SCRIPT_NAME -q filesystem snapshot "
        echo ""
        echo " -q will stop all echos and just list the changes"
        echo ""
        echo "Examples"
        echo "    $SCRIPT_NAME /home/fred    /home/.zfs/snapshot/fred "
        echo "    $SCRIPT_NAME .             /home/.zfs/snapshot/fred "   
        echo ""
        echo ""
        exit 1
}

########### Main Part ###################


## Check Usage
#
if [ $# -ne 2 ]; then
    Usage
fi

## Check we have different directories
#
if [ "$1" = "$2" ]; then
    Usage
fi


##  Handle dot
#
if [ "$FILESYSTEM" = "." ]; then
    cd $FILESYSTEM ; FILESYSTEM=`pwd`
fi
if [ "$SNAPSHOT" = "." ]; then
    cd $SNAPSHOT ; SNAPSHOT=`pwd`
fi

## Check the filesystems exists It should be a directory
#  and it should have some files
#
for FS in "$FILESYSTEM" "$SNAPSHOT"
do
    if [ ! -d "$FS" ]; then
        echo ""
        echo "ERROR file system $FS does not exist"
        echo ""
        exit 1
    fi   
    if [ X"`/bin/ls "$FS"`" = "X" ]; then
        echo ""
        echo "ERROR file system $FS seems to be empty"
        exit 1
        echo ""
    fi
done



## Create the bart files
#

echo ""
echo "Creating bart file for $FILESYSTEM can take a while......"
cd "$FILESYSTEM" ; $BART create -R . > $FILESYSTEM_BART_FILE
echo ""
echo "Creating bart file for $SNAPSHOT can take a while......"
cd "$SNAPSHOT" ; $BART create -R . > $SNAPSHOT_BART_FILE


## Compare them and report the diff
#
echo ""
echo "Changes...."
echo ""
$BART compare -p $FILESYSTEM_BART_FILE $SNAPSHOT_BART_FILE | awk '{print $1}' > $CHANGED_FILES
/bin/more $CHANGED_FILES
echo ""
echo ""
echo ""

## Tidy kiwi
#
/bin/rm $FILESYSTEM_BART_FILE
/bin/rm $SNAPSHOT_BART_FILE
/bin/rm $CHANGED_FILES

exit 0





Paul Archer wrote:
5:12pm, Cyril Plisko wrote:

  
Question: Is there a facility similar to inotify that I can use to monitor a
directory structure in OpenSolaris/ZFS, such that it will block until a file
is modified (added, deleted, etc), and then pass the state along (STDOUT is
fine)? One other requirement: inotify can handle subdirectories being added
on the fly. So if you use it to monitor, for example, /data/images/incoming,
and a /data/images/incoming/100canon directory gets created, then the files
under that directory will automatically be monitored as well.
      
while there is no inotify for Solaris, there are similar technologies available.

Check port_create(3C) and gam_server(1)

    
I can't find much on gam_server on Solaris (couldn't find too much on it at 
all, really), and port_create is apparently a system call. (I'm not a 
developer--if I can't write it in BASH, Perl, or Ruby, I can't write it.)
I appreciate the suggestions, but I need something a little more pret-a-porte.

Does anyone have any dtrace experience? I figure this could probably be done 
with dtrace, but I don't know enough about it to write a dtrace script 
(although I may learn if that turns out to be the best way to go). I was 
hoping that there'd be a script out there already, but I haven't turned up 
anything yet.

Paul
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss
  

www.eagle.co.nz 

This email is confidential and may be legally privileged. If received in error please destroy and immediately notify us.

_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to