LoginSignup
37
39

More than 5 years have passed since last update.

logmon でかんたんにログ監視

Last updated at Posted at 2015-03-31

logmon は IBMの作成したログ監視用perlスクリプトです。
1ファイル100行程度のスクリプトですが、十分実用的です。

インストール

githubにIBMのオリジナルにパッチをあてたものものがアップされているので、こちらを使うと楽ちんです。

$ git clone https://github.com/moomindani/logmon.git
$ cd logmon
$ sudo ./setup.sh

参考: CloudWatchとlogmonでEC2 Linuxのログを監視する | mooapp

設定

設定ファイルは、/etc/logmon/logmon.conf です。

書式は、下記のような感じになります。
設定ファイルは1つですが、下記の設定を複数記述することで複数のログを監視することもできます。

:ファイル名
(監視文字列)
コマンド

例: /var/log/messagesにERROR という文字列を発見したら、me@example.com にメールを送る

:/var/log/messages
(ERROR)
echo -e "ERROR\n<%%%%>\n" | mail -s "logmon alert" me@example.com

設定したら設定をチェックし、再起動します。

チェック

$ sudo service logmon check

logmonの再起動

$ sudo service logmon restart

参考

37
39
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
37
39