はじめに
MacOS Xには,/var/log/daily.outというファイルがあるが,これが肥大化している事を発見したのが調査の発端.どれくらい肥大化していたかというとこんな感じ.
sh-3.2# ls -lah /var/log/daily.out -rw-r--r-- 1 root wheel 38G Feb 1 03:20 /var/log/daily.out sh-3.2#
38GBの単一ファイルも凄いが,実は2007年から蓄積されたファイルなのでほぼ7年! 一旦消してみて溜まり具合いを調べてみたら,1日25MB程度づつ増えている模様.
sh-3.2# pwd /var/log sh-3.2# ls -lah daily.out* -rw-r--r-- 1 root wheel 28M Feb 15 03:17 daily.out -rw-r--r-- 1 root wheel 26M Feb 14 03:15 daily.out.20140214 -rw-r--r-- 1 root wheel 330M Feb 13 03:16 daily.out.old.20140213 sh-3.2#
と言う事でこれをできるだけ少なくして行く.
daily.outとは何なのか
daily.outとは,LinuxではなくBSD系のOSにあるもので,その名の通り日次処理のログ出力です.日次で実行されている処理は,以下のディレクトリ配下に保存されています.
/private/etc/periodic/daily/
早速そのディレクトリをみてみます.
sh-3.2# ls -la /private/etc/periodic/daily/ total 16 drwxr-xr-x 15 root wheel 510 Dec 1 2009 . drwxr-xr-x 5 root wheel 170 May 19 2009 .. -r-xr-xr-x 1 root wheel 1389 May 19 2009 100.clean-logs -r-xr-xr-x 1 root wheel 1592 May 19 2009 110.clean-tmps -r-xr-xr-x 1 root wheel 695 May 19 2009 130.clean-msgs -r-xr-xr-x 1 root wheel 1056 May 19 2009 140.clean-rwho -r-xr-xr-x 1 root wheel 378 May 19 2009 199.clean-fax -r-xr-xr-x 1 root wheel 1211 May 19 2009 310.accounting -r-xr-xr-x 1 root wheel 522 May 19 2009 400.status-disks -r-xr-xr-x 1 root wheel 548 May 19 2009 420.status-network -r-xr-xr-x 1 root wheel 687 May 19 2009 430.status-rwho -r-xr-xr-x 1 root wheel 4179 Jul 8 2007 500.daily~previous -rwxr-xr-x 1 root wheel 8439 May 19 2009 600.daily.server -rwxr-xr-x 1 root wheel 4539 May 19 2009 700.daily.server.mail -r-xr-xr-x 1 root wheel 712 May 19 2009 999.local sh-3.2#
ファイル名から,クリーニング系とステータス表示系があります.それぞれの中身を確認してみます
100.clean-logs
そのなの通り,ログをクリアします.古いログを見つけて,削除します. まずは,諸設定がこのファイルに保存されています.
/etc/defaults/periodic.conf
この設定ファイルの通りに動作するのですが,$daily_clean_logs_dirs にあるファイルで,$daily_clean_logs_days経過したファイルを消すという処理です.実際の設定ファイルの中身をみてみます.
sh-3.2# grep daily_clean_logs_days /etc/defaults/periodic.conf daily_clean_logs_days="60" # If not accessed for sh-3.2# grep daily_clean_logs_dirs /etc/defaults/periodic.conf daily_clean_logs_dirs="/Library/Logs/CrashReporter" # Delete under here sh-3.2#
つまり,これはCrash Reportで作成されたトレースファイルを,60日経過してたら消すという事になります.
110.clean-tmps
このシェルも100.clean-logsとほぼ同じ作りなのでパラメータを確認してみます.
daily_clean_tmps_days daily_clean_tmps_dirs
sh-3.2# grep daily_clean_tmps_days /etc/defaults/periodic.conf daily_clean_tmps_days="3" # If not accessed for sh-3.2# grep daily_clean_tmps_dirs /etc/defaults/periodic.conf daily_clean_tmps_dirs="/tmp" # Delete under here sh-3.2#
3日以上経過した/tmp以下のファイルを消すと言う事になります.作業用ファイルを/tmp以下に作っておけば,3日で消してくれると言う事になります.
130.clean-msgs
daily_clean_msgs_days /var/msgs
これも設定をみてみる.
sh-3.2# grep daily_clean_msgs_days /etc/defaults/periodic.conf daily_clean_msgs_days= # If not modified for sh-3.2#
何も定義されてない.msgsという仕組みがあり,OSへログインした時にシステムから通知されるメッセージブロードキャストの仕組みだけれど,現在はGUIだし使われてないものと言えます.過去の名残です.
140.clean-rwho
daily_clean_rwho_days /var/rwho
UNIXにはwhoというコマンドがあって,現在そのホストにログインしているユーザ一覧を出力しますが,それのリモート版です.ローカルネットワーク上の全てのマシンについてwhoと似た出力を行なうものです.これも実質あまり使われないのではなかろうか.
400.status-disks
daily_status_disks_df_flags dfコマンド
dfコマンドをdaily_status_disks_df_flagsにあるパラメータを実行します.フラグの内容はこんな感じです.
sh-3.2# grep daily_status_disks_df_flags /etc/defaults/periodic.conf daily_status_disks_df_flags="-l -h" # df(1) flags for check sh-3.2#
実際に実行するとこんな感じです.
sh-3.2# df -l -h Filesystem Size Used Avail Capacity Mounted on /dev/disk0s2 149Gi 82Gi 66Gi 56% / /dev/disk1s3 298Gi 248Gi 50Gi 84% /Volumes/JunoTM sh-3.2#
600.daily.server
このシェルはPerlになります.その名の通りサーバ用のdailyシェルです.
/etc/diskspacemonitor/daily.server.conf /var/log/diskspacemonitor.log
daily.server.confに設定が書かれています.ファイルを圧縮したり削除したり.次のようなフォーマットでログが指定してあります.
filename pattern : # versions : threshold in MB : threshold in days : action : process name : signal
まずは,このファイル.これはcompressが指定してあります.
/Library/Logs/AppleFileService/AppleFileService*.log*[0-9]*[0-9] : 0 : 50 : 14 : compress : :
このファイルはファイル共有サービスのログ
/Library/Logs/WebServer/*error_log.[0-9]*[0-9] : 0 : 50 : 14 : compress : : /Library/Logs/WebServer/*access_log.[0-9]*[0-9] : 0 : 50 : 14 : compress : :
これはWebサーバ.実際には,/var/log/apache2へのリンク.
/var/log/diskspacemonitor.log : 5 : 50 : 9999 : roll : :
/var/log/slapd.log : 5 : 50 : 9999 : roll : syslogd : HUP /Library/Logs/slapconfig.log : 5 : 50 : 9999 : roll : :
これはLDAP関連.
/var/log/ppp/vpnd.log : 5 : 50 : 9999 : roll : vpnd : HUP
VPNサーバとして使っているとログされる様です.
/var/log/httpd/mod_jk.log : 5 : 50 : 9999 : roll : : /var/log/apache2/mod_jk.log : 5 : 50 : 9999 : roll : :
WebサーバでJavaアプリを連携して動かしている時のログ.
/var/log/securityproxy/calDAV_access.log : 5 : 50 : 9999 : roll : httpd : HUP /var/log/securityproxy/cardDAV_access.log : 5 : 50 : 9999 : roll : httpd : HUP /var/log/securityproxy/web_access.log : 5 : 50 : 9999 : roll : httpd : HUP /var/log/securityproxy/httpd_error.log : 5 : 50 : 9999 : roll : httpd : HUP /var/log/securityproxy/secure_proxy_login.log : 5 : 50 : 9999 : roll : httpd : HUP /var/log/securityproxy/mail_access.log : 5 : 50 : 9999 : roll : syslogd : HUP /var/log/securityproxy/mail_error.log : 5 : 50 : 9999 : roll : syslogd : HUP
カレンダーサーバ,メールサーバでセキュリティプロキシを使っているときの出るログのようです.ちょっと不明.
/var/log/swupd/swupd_access_log : 5 : 50 : 9999 : roll : httpd : HUP /var/log/swupd/swupd_error_log : 5 : 50 : 9999 : roll : httpd : HUP /var/log/swupd/swupd_syncd_log : 5 : 50 : 9999 : roll : httpd : HUP
これはソフトウェアアップデート関連です.Windows でいうところのSUSのようなものを構築した際にログ出力される様です.
700.daily.server.mail
このシェルもPerl.
/var/log/mailaccess.log /var/log/mail.log /var/log/amavis.log /var/log/clamav.log /var/log/freshclam.log /var/log/mailman/*
mailaccess.logとmail.logはPostfix関連のログ.amavis.logはamavisd-newというウイルススキャナとの連携ソフト.そしてClam AntiVirusがその名の通り連携先のアンチウイルスソフト. freshclam.logにウイルスパターンファイルのログ更新履歴が残っている. mailmanはメーリングリストのソフト.
amavisd-new http://www.amavis.org