「inotify-tools」の版間の差分

提供: セキュリティ
移動: 案内検索
(関連項目)
行89: 行89:
  
 
== 関連項目 ==
 
== 関連項目 ==
* [[inotify]]
+
{{inotify}}
* [[Tripwire]]
+
 
* [[ファイルシステム]]
 
* [[ファイルシステム]]
 
* [[ファイル改竄検知]]
 
* [[ファイル改竄検知]]
 
* [[監視]]
 
* [[監視]]
<!--
+
<!-- vim: filetype=mediawiki -->
vim: filetype=mediawiki
+
-->
+

2014年2月6日 (木) 21:47時点における版

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

関連項目