「inotify-tools」の版間の差分

提供: セキュリティ
移動: 案内検索
(関連項目)
 
行5: 行5:
 
__TOC__
 
__TOC__
 
== 概要 ==
 
== 概要 ==
[[inotifywatch]] は、[[inotify]] を使用して、[[ファイルシステム]]へのアクセスの統計情報を集めます。
+
'''inotifywatch''' は、[[inotify]] を使用して、[[ファイルシステム]]へのアクセスの統計情報を集めます。
[[inotifywatch]] は、[[Linux]] の [[inotify]](7)インターフェースを使用して、[[ファイルシステム]]のイベントをリッスンします。それぞれのファイルやディレクトリのイベントを受取、サマリーをカウントして出力します。
+
'''inotifywatch''' は、[[Linux]] の [[inotify]](7)インターフェースを使用して、[[ファイルシステム]]のイベントをリッスンします。それぞれのファイルやディレクトリのイベントを受取、サマリーをカウントして出力します。
 
+
[[inotifywait]] は、[[inotify]] を使用して、ファイルの変更を待ちます。
+
[[inotifywait]] は、[[Linux]] の[[inotify]](7)インターフェースを使用して、ファイルの変更を待ちます。シェルスクリプトによってファイルが変更されるのと待つのに最適です。イベントが発生すると、すぐに終了します。
+
  
 +
'''inotifywait''' は、[[inotify]] を使用して、ファイルの変更を待ちます。
 +
'''inotifywait''' は、[[Linux]] の[[inotify]](7)インターフェースを使用して、ファイルの変更を待ちます。シェルスクリプトによってファイルが変更されるのと待つのに最適です。イベントが発生すると、すぐに終了します。
 
== パッケージの内容 ==
 
== パッケージの内容 ==
 
 
[[inotify-tools]] のバージョン 3.13のパッケージの内容です。
 
[[inotify-tools]] のバージョン 3.13のパッケージの内容です。
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
行29: 行27:
 
/usr/share/man/man1/inotifywatch.1.gz
 
/usr/share/man/man1/inotifywatch.1.gz
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
== インストール ==
 
== インストール ==
 
 
{{yum|inotify-tools}}
 
{{yum|inotify-tools}}
 
{{apt|inotify-tools}}
 
{{apt|inotify-tools}}
 
 
== 使い方 ==
 
== 使い方 ==
 
 
=== inotifywatch ===
 
=== inotifywatch ===
 
2つのターミナルを用意します。
 
2つのターミナルを用意します。
  
1つ目のターミナルで [[inotifywatch]] を実行します。
+
1つ目のターミナルで '''inotifywatch''' を実行します。
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ inotifywatch -r /tmp/
 
$ inotifywatch -r /tmp/
行52: 行46:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
1つめのターミナルで C-c で [[inotifywatch]] を終了させます。
+
1つめのターミナルで C-c で '''inotifywatch''' を終了させます。
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ inotifywatch -r /tmp/
 
$ inotifywatch -r /tmp/
行61: 行55:
 
3      1      1            1    /tmp/inotify-test/
 
3      1      1            1    /tmp/inotify-test/
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
=== inotifywait ===
 
=== inotifywait ===
これは、[[inotifywait]] でディレクトリ /tmp を監視する例です。
+
これは、'''inotifywait''' でディレクトリ /tmp を監視する例です。
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ inotifywait /tmp
 
$ inotifywait /tmp
行82: 行75:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
以下のように [[inotifywait]] によって検知されます。
+
以下のように '''inotifywait''' によって検知されます。
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
2013-10-05 17:47:30 /etc/ XXX CREATE
 
2013-10-05 17:47:30 /etc/ XXX CREATE
 
2013-10-05 17:47:30 /etc/ XXX ATTRIB
 
2013-10-05 17:47:30 /etc/ XXX ATTRIB
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
== 関連項目 ==
 
== 関連項目 ==
 
{{inotify}}
 
{{inotify}}
行93: 行85:
 
* [[ファイル改竄検知]]
 
* [[ファイル改竄検知]]
 
* [[監視]]
 
* [[監視]]
<!-- vim: filetype=mediawiki -->
+
<!-- vim: filetype=mediawiki
 +
-->

2015年9月22日 (火) 17:58時点における最新版

inotify-tools とは、inotify のシンプルなインターフェースを提供する Linux 向けのコマンドラインプログラムのセットです。

読み方

inotify-tools
あいのーてぃふぁい つーるず

概要

inotifywatch は、inotify を使用して、ファイルシステムへのアクセスの統計情報を集めます。 inotifywatch は、Linuxinotify(7)インターフェースを使用して、ファイルシステムのイベントをリッスンします。それぞれのファイルやディレクトリのイベントを受取、サマリーをカウントして出力します。

inotifywait は、inotify を使用して、ファイルの変更を待ちます。 inotifywait は、Linuxinotify(7)インターフェースを使用して、ファイルの変更を待ちます。シェルスクリプトによってファイルが変更されるのと待つのに最適です。イベントが発生すると、すぐに終了します。

パッケージの内容

inotify-tools のバージョン 3.13のパッケージの内容です。

$ rpmquery -l inotify-tools
/usr/bin/inotifywait
/usr/bin/inotifywatch
/usr/lib64/libinotifytools.so.0
/usr/lib64/libinotifytools.so.0.4.1
/usr/share/doc/inotify-tools-3.13
/usr/share/doc/inotify-tools-3.13/AUTHORS
/usr/share/doc/inotify-tools-3.13/COPYING
/usr/share/doc/inotify-tools-3.13/ChangeLog
/usr/share/doc/inotify-tools-3.13/NEWS
/usr/share/doc/inotify-tools-3.13/README
/usr/share/man/man1/inotifywait.1.gz
/usr/share/man/man1/inotifywatch.1.gz

インストール

CentOSにインストールする場合

CentOSyum コマンドでインストールする場合。

sudo yum -y  install inotify-tools

Ubuntu/Debianにインストールする場合

apt-get コマンドでインストールする場合です。

sudo apt-get install inotify-tools

使い方

inotifywatch

2つのターミナルを用意します。

1つ目のターミナルで inotifywatch を実行します。

$ inotifywatch -r /tmp/
Establishing watches...
Finished establishing watches, now collecting statistics.

2つめのターミナルで、監視対象のディレクトリのファイルに対して、コマンドを実行します。

$ echo hoge >> /tmp/inotify-test/abc

1つめのターミナルで C-c で inotifywatch を終了させます。

$ inotifywatch -r /tmp/
Establishing watches...
Finished establishing watches, now collecting statistics.
^C
total  modify  close_write  open  filename
3      1       1            1     /tmp/inotify-test/

inotifywait

これは、inotifywait でディレクトリ /tmp を監視する例です。

$ inotifywait /tmp
Setting up watches.
Watches established.
/tmp/ CREATE man.UI49mr

inotifywait によるシステム監視

/etc を監視する例です。

sudo inotifywait -m -e create,delete,modify,move,attrib \
--format '%T %w %f %e' -r --timefmt '%F %T' /etc

/etc にファイルを作成してみます。

sudo touch /etc/XXX

以下のように inotifywait によって検知されます。

2013-10-05 17:47:30 /etc/ XXX CREATE
2013-10-05 17:47:30 /etc/ XXX ATTRIB

関連項目