Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

24.4.7. gamin によるファイルおよびディレクトリーの監視

Red Hat Enterprise Linux 6.8 以降、GLib システムライブラリーはファイルとディレクトリーの監視、NFS ファイルシステムでの変更の検出に gamin を使用します。デフォルトでは、gamininotify ではなく NFS ファイルシステムのポーリングを使用します。他のファイルシステムの変更は、GLib に直接実装される inotify monitor により監視されます。
File Alteration Monitor(FAM)システムのサブセットとして inotify Linux カーネルサブシステムで FAM 仕様を再実装します。これは GNOME プロジェクトですが、GNOME 依存関係はありません。glib2 パッケージと gamin パッケージの両方はデフォルトでインストールされます。
デフォルトでは、gamin は設定なしで機能し、Linux では /mnt/* または / media/ * に一致するすべてのパスのポーリングの使用に戻ります。ユーザーは、以下の設定をオーバーライドするか、または拡張するには、以下のいずれかの設定ファイルの内容を変更します。
  • /etc/gamin/gaminrc
  • $HOME/.gaminrc
  • /etc/gamin/mandatory_gaminrc
設定ファイルは以下のコマンドのみを受け入れます。

設定ファイルで使用できるコマンド

notify
カーネルモニタリングを一致するパスに使用する必要があることを示すには、以下を行います。
poll
一致するパスにポーリングを使用することを表すには、以下を行います。
fsset
ファイルシステムタイプで使用される通知メソッドを制御する。
このような設定ファイルの例は、以下を参照してください。
# configuration for gamin
# Can be used to override the default behaviour.
# notify filepath(s) : indicate to use kernel notification
# poll filepath(s)   : indicate to use polling instead
# fsset fsname method poll_limit : indicate what method of notification for the file system
#                                  kernel - use the kernel for notification
#                                  poll - use polling for notification
#                                  none - don't use any notification
#                                  the poll_limit is the number of seconds
#                                  that must pass before a resource is polled again.
#                                  It is optional, and if it is not present the previous
#                                  value will be used or the default.
notify /mnt/local* /mnt/pictures* # use kernel notification on these paths
poll /temp/*                      # use poll notification on these paths
fsset nfs poll 10                 # use polling on nfs mounts and poll once every 10 seconds
この順序で、3 つの設定ファイルが読み込まれます。
  1. /etc/gamin/gaminrc
  2. ~/.gaminrc
  3. /etc/gamin/mandatory_gaminrc
/etc/gamin/mandatory_gaminrc 設定ファイルを使用すると、システム管理者は、ユーザーが設定した潜在的な危険性のある設定をオーバーライドできます。ポーリングまたはカーネル通知のいずれを使用すべきかを推測すべきパスを確認すると、gamin は最初に、設定ファイル内のユーザーが指定したルールの順番をチェックしてから、事前定義済みのルールをチェックします。これにより、例にある /mnt/local* の最初の宣言は、/ mnt/* のデフォルトの宣言を上書きします
gamin が特定のパスでポーリング通知を使用するように設定されていない場合は、パスが存在するファイルシステムに基づいて決定されます。