LoginSignup
17
19

More than 5 years have passed since last update.

logwatchに感動した

Last updated at Posted at 2013-12-09

インストール

インストール
$ sudo apt-get install logwatch

バージョン確認

$logwatch --version
Logwatch 7.4.0 (released 03/01/11)
  • lm_sensorsも入れると良い。

設定

ひな形をコピー
$ sudo cp /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/
/etc/logwatch/conf/logwatch.conf
- Format = html
+ Format = text
+ MailTo = root
- Detail = Low
+ Detail = Med
+ Service = "-postfix" #postfixのログを除外
+ mailer = "/usr/sbin/sendmail.postfix -t"

動作テスト

標準出力
$ sudo /usr/sbin/logwatch --output stdout
debian
$ sudo /etc/cron.daily/00logwatch
centos
$ sudo /etc/cron.daily/0logwatch

注意点

作業用ディレクトリ確認
TmpDir = /var/cache/logwatch

処理を途中で中断してしまった場合、$TmpDir/logwatch?????という一時ディレクトリが作成され、
次回以降実行ができなくなるので、一般ユーザーで実行してしまった->中断
をした場合など注意。

ログファイル追加

ひな形からコピー
cp /usr/share/logwatch/default.conf/logfiles/http.conf \
 /etc/logwatch/conf/logfiles/http.conf
/etc/logwatch/conf/logfiles/http.conf
+LogFile = httpd/*/access_log
+LogFile = httpd/*/error_log
+Archive = httpd/*/access_log.1.gz
+Archive = httpd/*/error_log.1.gz

除外したいログがある場合は以下のように書く。

LogFile = httpd/[!sv]*/access_log
Archive = httpd/[!sv]*/access_log.1.gz
  • CentOS4のlogwatchは /etc/log.d/conf/logfiles/

Disk space にチェック対象を追加

スクリプトをコピー
sudo cp -a /usr/share/logwatch/scripts/services/zz-disk_space /etc/logwatch/scripts/services/
/etc/logwatch/scripts/services/zz-disk_space
 sub DiskSpace ()
 {
    if ($OSname eq "Linux") {
-      $df_options = "-h -l -x tmpfs";
+      $df_options = "-h -x tmpfs";
動作確認
sudo /etc/cron.daily/0logwatch
17
19
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
17
19