#freeze
* [[Nagios]]
ネットワークサービスの監視ツールです。サーバが増えてきて管理が大変になってきたので、いれてみました。ZABBIXというのがあり気になっているところではあります。
#contents

** インストール
http://www.nagios.org/からnagios-2.0.tar.gzをダウンロードしました。
 tar xzvf nagios-2.0.tar.gz
展開されたディレクトリにINSTALLINGファイルがあり、その中に、
 ./configure --prefix=PREFIX --with-cgiurl=CGIURL --with-htmurl=HTMURL
 --with-nagios-user=SOMEUSER --with-nagios-grp=SOMEGROUP
とありますので、まずnagios用にユーザとグループを作成します。
 groupadd nagios
 useradd -d /usr/local/nagios -g nagios nagios -s /bin/false
またINSTALLINGファイルにデフォルトの値が書いてありますので、それを参考にconfigureを実行して、
 ./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin 
 --with-htmurl=/nagios --with-nagios-user=nagios 
 --with-nagios-group=nagios
 make all
 make install
 make install-config #/etc/init.d/nagiosができているはず
 make install-init
では次にhttp://www.nagios.org/download/からPluginsをダウンロードします。INSTALLファイルより./configure --helpを実行して、必要なものを設定します。
 tar xzvf nagios-plugins-1.4.tar.gz
 ./configure --prefix=PREFIX --with-cgiurl=CGIURL --with-nagios-user=SOMEUSER
 --with-nagios-grp=SOMEGROUP
 make all
 make install
また必要に応じて、http://www.nagios.org/download/extras.phpからダウンロードします。次にetcにsampleがあるのでコピーします。
 cp -p bigger.cfg-sample        bigger.cfg
 cp -p cgi.cfg-sample           cgi.cfg
 cp -p checkcommands.cfg-sample checkcommands.cfg
 cp -p minimal.cfg-sample       minimal.cfg
 cp -p misccommands.cfg-sample  misccommands.cfg
 cp -p nagios.cfg-sample        nagios.cfg
 cp -p resource.cfg-sample      resource.cfg
さてブラウザからアクセスしてみましょう。
 Error: Could not read object configuration data!
 Here are some things you should check in order to resolve this error:
   1. Verify configuration options using the -v command-line option to check for errors.
   2. Check the Nagios log file for messages relating to startup or status data errors.
   3. Make sure you've compiled the main program and the CGIs to use the same object data storage options (i.e. default text file or template-based file). 
ん~ どれ押しても上記のメッセージです。nagios.cnfをみてみると、cfg_fileがいつくか定義されているので、cfg_file=/usr/local/nagios/etc/minimal.cfgを残してコメントして、
 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
を実行すると
 Total Warnings: 0
 Total Errors:   0
とは出てました。エラーがでている場合は、直しておきましょう。では、サービスを立ち上げます。
 chkconfig --add nagios
 /etc/init.d/nagios start
ではブラウザからアクセスしてみましょう。ちょっと前進しましたが、
 It appears as though you do not have permission to view information for any of the services you requested...
とエラーが出力さてます。cgi.cfgの
 use_authentication=1
になっている場合、認証が必要となるので、とりあえずいまは設定していなかったので、0にしてやりました。1にする場合は、authorized_for_all_servicesとかのauthorized_forで始まる設定を見直しておきましょう。ではちょっとcfgを見直しておきます。
nagios.cfgで
 date_format=us
を
 date_format=iso8601        # (YYYY-MM-DD HH:MM:SS)

 admin_email=nagios
を
 admin_email=nagios@hoge.ho
minimal.cfgのdefine contact{.. emailを修正

httpd.conf
 ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin/
 Alias /nagios "/usr/local/nagios/share/"
 <Location /nagios>
       Options Indexes FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from All
       AuthName "Nagios Access"
       AuthType Basic
       AuthUserFile /usr/local/nagios/etc/htpasswd
       require valid-user
 </Location>
 <Location "/usr/local/nagios/sbin/">
       Options ExecCGI FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from All
 </Location>

パスワード作成
 cd /usr/local/nagios/etc
 htpasswd -cb htpasswd nagiosadmin hogehoge
cgi.cfg
 authorized_forで始まる行のコメントをとりnagiosadminを追加

**プラグイン
 /usr/local/nagios/libexec/check_http --help
とかしてヘルプを見ておきましょう。
http://cubic9.com/Nagios/に丁寧な解説があります。

**TIPS
***qmailで送信
http://www.b-dash.net/solaris/nagios.html
**未解決
ログを見ているとvar/nagios.logに
 Error: Cannot open main configuration file '/usr/local/nagios/bin/d' for
と出力されてます。なんだ?

** リンク
http://nagios.x-trans.jp/Nagios-doc/JAPANESE/~
[[Nagiosでネットワークを監視する>http://pcweb.mycom.co.jp/column/yetanother/075/]]~
[[Webサーバの24×365監視を実現する>http://www.atmarkit.co.jp/fnetwork/rensai/netman05/netman01.html]]~
http://www.atmarkit.co.jp/fnetwork/rensai/netman06/netman01.html~

** 参考書籍

** コメント
-#comment

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS