アイウォッチ

アイウォッチ

私はドラッグ アンド ドロップを使用してファイルをコピーおよび移動します。その欠点の 1 つは、ファイルが間違った場所に移動される可能性があることです。そこで、多数のファイルとフォルダーを複数の異なる宛先にコピー/移動したとします。

すべてが正しい場所にコピー/移動されたことを確認するために、すべてがどこに保存されたかを追跡するにはどうすればよいでしょうか?

答え1

あなたが求めているのは「ファイル システム ウォッチャー」です。

アイウォッチ iWatchをインストールする

iWatch はリアルタイムのファイルシステム監視プログラムです。特定のディレクトリ/ファイルの変更を監視し、すぐに電子メール通知を送信するシンプルな Perl スクリプトです。xml 構成ファイルからディレクトリ/ファイル リストを読み取り、カーネル (Linux カーネル >= 2.6.13) の inotify サポートが必要です。

他にも方法はありますが、これは最も簡単な方法のようです。Ubuntu ネイティブで、inotify を使用します (そのため、システムを占有しません)。

iWatch には 2 つの方法があります:

  1. コマンドライン
  2. デーモン

ログ記録用のコマンドライン オプションの一部:

-m <email address>
   Specify the contact point's email address. Without this option, iwatch will 
   not send any email notification. 

-s <on|off>
   Enable or disable reports to the syslog (default is off/disabled)

コマンドラインの例:

iwatch /tmp

デフォルトのイベントで /tmp ディレクトリの変更を監視する

iwatch -r -e access,create -m cahya@localhost -x /etc/mail /etc

/etc/mail を例外として /etc ディレクトリへのアクセスとイベントの作成のみを再帰的に監視し、cahya@localhost に電子メール通知を送信します。

iwatch -r -c "(w;ps -ef)|mail -s '%f was changed' cahya@localhost" /bin

/bin ディレクトリを再帰的に監視し、コマンドを実行します。

iwatch -r -X '\.svn' ~/projects

~/projects ディレクトリを再帰的に監視しますが、内部の .svn ディレクトリは除外します。'-x' は定義されたパスのみを除外できるため、通常の '-x' オプションではこれを行うことはできません。


設定ファイルの例デーモン モードを使用する場合。ログ記録は構成ファイル内の XML オプションを使用して行われます。

<config>
  <guard email="myadmin@localhost" name="IWatch"></guard>
  <watchlist>
  <title>Public Website</title>
  <contactpoint email="webmaster@localhost" name="Web Master"/>
    <path type="single">/var/www/localhost/htdocs</path>
    <path type="single" syslog="on">/var/www/localhost/htdocs/About</path>
    <path type="recursive">/var/www/localhost/htdocs/Photos</path>
  </watchlist>
  <watchlist>
  <title>Operating System</title>
  <contactpoint email="admin@localhost" name="Administrator"/>
    <path type="recursive">/etc/apache2</path>
    <path type="single">/etc/passwd</path>
    <path type="recursive">/etc/mail</path>
    <path type="exception">/etc/mail/statistics</path>
    <path type="single" filter="shadow|passwd">/etc</path>
  </watchlist>
  <watchlist>
  <title>Only Test</title>
  <contactpoint email="root@localhost" name="Administrator"/>
    <path type="single" alert="off" exec="(w;ps -ef)|mail -s %f
      root@localhost">/tmp/dir1</path>
    <path type="single" events="access,close" alert="off" exec="(w;ps -ef)|mail -s %f
      root@localhost">/tmp/dir2</path>
    <path type="single" events="default,access" alert="off" exec="(w;ps -ef)|mail -s '%f is
      accessed' root@localhost">/tmp/dir3</path>
    <path type="single" events="all_events" alert="off">/tmp/dir4</path>
  </watchlist>
</config>

この設定では、iwatch はサブディレクトリのない単一のディレクトリを監視し/var/www/localhost/htdocs、すべての通知は連絡先 webmaster@localhost に送信されます。ただし、/etc/apache2IWatch の起動後に作成されたサブディレクトリを含む、ディレクトリ ツリー全体を監視します。監視対象ディレクトリ内のファイルまたはサブディレクトリに関する通知を受け取りたくない場合は、ここで例外を作成することもできます。

関連情報