現: 2009-08-19 (水) 00:45:52 maruo ソース
Line 1: Line 1:
 +[[Gentoo Linuxな生活/システム管理関連]]
 +*運用監視 [#ya9d698c]
 +サーバといっても、インストールして、動き出しさえすればOK!というわけではありません。動作状態は定期的に監視して、問題の発見、対処、ソフトのインストールなどせねばなりません。作ることよりも、維持することのほうが大変なんです。男と女の関係と一緒ですな。
 +
 +*Syslog [#d74e285e]
 +SyslogはUNIXにおける動作ログを収集するスタンダードです。動作のログ、エラーのログをとるものです。で、通常はこのログを監視していればいいのですが、''ログって結構量がおおいし、その中からだと、エラーの痕跡を見逃す場合もあるのですよ。
 +
 +*Syslog監視ツール [#w1aae74a]
 +そんなわけで、Syslog監視ツールなるものがあります。
 +:Swatch|リアルタイムで何か事があったら通知してくれるツール
 +:logwatch|ログファイルをスキャンして、ログの要約を通知してくれるツール
 +
 +と、あります。で、私が選んだのはlogwatchです。だってさぁ、四六時中サーバのそばにいるわけじゃあないからね。メールで動作状態が確認できれば一応十分なのですよ。
 +
 +**logwatchインストール [#q6d2084d]
 + emerge -b logwatch
 +
 +はい、インストール終了
 +**設定しましょう [#q426cacd]
 +/etc/log.dにlogwatch.confがあります。こいつを設定してやります。
 + #ログのある場所
 + LogDir = /var/log
 + #テンポラリエリア
 + TmpDir = /tmp
 + #メールを送る送付先
 + MailTo = XXXXX
 + #プリントアウトするかどうか
 + Print = No
 + #MkTempを使用するか
 + UseMkTemp = Yes
 + #いつのログを調査するか
 + Range = Yesterday
 + #ログ解析の詳細度
 + Detail = Low
 + どのサービスをチェックするか
 + Service = All
 + #メイルになんのツールを使用するか
 + mailer = /bin/mail
 +
 +ほとんどデフォルトで問題ありません。さて、ここで問題なのは、このlogwatch、Syslogdを使った場合のRedHatなんかの設定がデフォルトになっていまして、Syslog-ngのSyslog出力とちょっとあっていません。なので調整してあげる必要があります。
 +
 +**出力の調整 [#p796664d]
 +まず、構成から説明しますね
 +,/etc/log.d,logwatchの設定ルート
 +,/etc/log.d/conf,設定ファイルが入っている
 +,/etc/log.d/conf/logfiles,調べるlogファイル名の設定。
 +,/etc/log.d/conf/services,調べる動作サービスの設定
 +,/etc/log.d/scripts/,実際に調べるときに使うスクリプトファイル置き場
 +
 +となってます。
 +-/etc/log.d/conf/logfilesにどのファイルを調べるかを書いておく。(messagesとか、maillogとか)
 +-/etc/log.d/conf/servicesに、何のサービスについて、どのファイルを調べるかを書いておく。
 +
 +この2つでおっけーなはず。うちでは、amavis,apache,kernel,pam,postfix,samba,sshが該当してますね。
 +
 +ちと例を出すと、/etc/log.d/conf/services/postfix.conf
 + #####################################################
 + # $Id: postfix.conf,v 1.3 2004/02/03 03:52:18 kirk Exp $
 + #####################################################
 + 
 + # You can put comments anywhere you want to.  They are effective for the
 + # rest of the line.
 + 
 + # this is in the format of <name> = <value>.  Whitespace at the beginning
 + # and end of the lines is removed.  Whitespace before and after the = sign
 + # is removed.  Everything is case *insensitive*.
 + 
 + # Yes = True  = On  = 1
 + # No  = False = Off = 0
 + 
 + Title = postfix              ←/etc/log.d/scripts/services/postfixを使って調べる
 + 
 + # Which logfile group...
 + LogFile = messages      ←messagesを調べる。messagesの定義は
 +                                       /etc/log.d/conf/logfiles/massages.confを見ると解る
 + 
 + # Only give lines pertaining to the postfix service...
 + *OnlyService = "postfix/[a-zA-Z0-9]*"
 + # *OnlyService = "postfix/smtpd"
 + *RemoveHeaders =
 + 
 + #####################################################
 + # This was written and is maintained by:
 + #    Kenneth Porter <shiva@well.com>
 + #
 + # Please send all comments, suggestions, bug reports,
 + #    etc, to shiva@well.com.
 + #
 + #####################################################
 +
 +これはほとんど変更しておりません。で、次に/etc/log.d/conf/logfiles/messages.confを見てみると
 + #####################################################
 + # $Id: messages.conf,v 1.17 2002/10/13 15:24:27 kirk Exp $
 + #####################################################
 + 
 + #####################################################
 + # This was written and is maintained by:
 + #    Kirk Bauer <kirk@kaybee.org>
 + #
 + # Please send all comments, suggestions, bug reports,
 + #    etc, to kirk@kaybee.org.
 + #####################################################
 + 
 + # What actual file?  Defaults to LogPath if not absolute path....
 + LogFile = messages  ←ファイル名はmessages
 + 
 + # If the archives are searched, here is one or more line
 + # (optionally containing wildcards) that tell where they are...
 + # Note: if these are gzipped, you need to end with a .gz even if
 + #      you use wildcards...
 + Archive = messages.* ←固めた過去ファイルはmessages.*
 + Archive = messages.*.gz
 + 
 + # Expand the repeats (actually just removes them now)
 + *ExpandRepeats  ←アーカイブファイルもチェックする
 + 
 + # Now, lets remove the services we don't care about at all...
 + *RemoveService = talkd
 + *RemoveService = telnetd
 + *RemoveService = inetd
 + *RemoveService = nfsd
 + *RemoveService = /sbin/mingetty
 + 
 + # Keep only the lines in the proper date range...
 + *OnlyHost
 + *ApplyStdDate
 +
 +こんな感じ。これもデフォルトそのままです。結構簡単にいけますでしょう。で、もう一つ問題。ここで、デフォルトパッケージについてくるlogチェックスクリプトには、postfix,apache,amavis等が付いておりません。ですので、[[logwatchホームページのCVS:http://www2.cvs.logwatch.org:81/index.cgi/logwatch/]]にアクセスしてみます。すると、追加サービスのスクリプトが落ちていますので、ダウンロードしてきて先ほどの情報を元に設定してやります。すると、追加サービスについてログをチェックしてくれるようになるわけです。さて、さっきのPostfixだと、
 +
 + --------------------- postfix Begin ------------------------
 + 5856267 bytes transferred
 + 89 messages sent
 + 
 + Messages sent by:
 +   XXXXXX (uid=XX):  : X Time(s)
 +   XXXXXX (uid=X):  : X Time(s)
 + 
 + 
 + Relaying denied:
 +   From unknown[211.49.139.241] to username@put_a_valid_domain.com : 1 Time(s)
 +
 +さて、コレを見て解ること。誰かが不正中継を要求してきてますネ。211.49.139.241だれ?これって感じ。ほかにも、apacheがウィルスの攻撃をはじいたログも出てました。本日も安泰でした。
 +
 +*最後に [#f05c1968]
 +logwatchを入れたから安心、というわけでは在りません。実際にlogを監視することも重要です。あくまでもログ監視作業を補完するツールであるという事をお忘れなく♪
  

  • Syslog監視 のバックアップ差分(No. All)
    • 現: 2009-08-19 (水) 00:45:52 maruo

トップ   差分 バックアップ 複製 名前変更 リロード印刷に適した表示   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom Powered by xpWiki
Counter: 26244, today: 1, yesterday: 0
ページ内検索

ログイン

ユーザー名:


パスワード:





パスワード紛失

メインメニュー

サブメニュー
自宅鯖計画

Gentoo Linuxな生活

玄箱HGにGentoo格闘記

航空ショーへ行こう

モータースポーツな世界

奥深き写真の世界への誘い

我思う ゆえに我あり



携帯用QRコード