2006/12/06

Hobbitサーバー インストール

ポスト @ 1:43:58 | Software

公開サーバーともなると自分が使うときだけ動いていればいいというわけにもいかず、ちょうど『Software Design』2006年12月号の「サーバ&ネットワーク モニタリング大全」という特集で Hobbit Monitor という監視ソフトが紹介されており、お手軽そうなので導入してみることにした。Hobbitはサービスの監視はもちろんリソースの監視も行え、サービスが停止していたりリソースがしきい値を越えたときに、Webで一覧表示したりメールで通知してくれたりするのが主な機能だ。これでサーバーの異常を瞬時に把握することができるようになる。

Hobbitを動作させるには大きく分けて三つのステップがある。「サーバーのインストール」「クライアントのインストール」「監視項目 / しきい値 / アラート・メールの設定」だ。このエントリーでは、まず「サーバーのインストール」のみ説明する。HobbitはUnix系OSならどれでも利用できるが、今回、OSはLinux、ディストリビューションはCentOSを使う。

はじめに、Hobbitが必要なソフトウェアがすでにインストール済みであるかどうかを確認しよう。

  • fping
  • httpdなどのWebサーバー
  • openldap-devel
  • openssl-devel
  • pcre-devel
  • rrdtool-devel

fpingとrrdtool-develはCentOSでは提供されていないが、DAGにRPMがあるのでそこからダウンロードすると簡単だ。DAGのWebサイトからそのまま落とすのもいいけど、yumやup2dateにDAGをリポジトリとして登録しておくと簡単にアップデートできるので便利だろう。DAGをyumのリポジトリに追加する方法は 複眼中心: ClamAVのインストール を参照してほしい。

以下はyumを使ったダウンロード方法である。

# yum install fping Setting up Install Process Setting up repositories dag 100% |=========================| 1.1 kB 00:00 ...... Installed: fping.i386 0:2.4-1.b2.2.el4.rf Complete! # yum install rrdtool-devel Setting up Install Process Setting up repositories dag 100% |=========================| 1.1 kB 00:00 ...... Installed: rrdtool-devel.i386 0:1.2.15-1.el4.rf Complete!

必要なライブラリのインストールが終わったら、Hobbitを実行するユーザーを作成しておこう。

# useradd -c 'Hobbit Administrator' hobbit # passwd hobbit Changing password for user hobbit. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully.

fpingはそのままでは一般ユーザーで実行できないので、fpingのグループとパーミッションを変更する。fpingはsetuidビットがオンなので、一般ユーザーすべてに実行させるのは念のため避けた。

# chgrp hobbit /usr/sbin/fping # chmod g+x /usr/sbin/fping # ls -l /usr/sbin/fping -rws--x--- 1 root hobbit 29850 2月 17 2005 /usr/sbin/fping

これで関連ソフトウェアの準備は完了だ。つづいてHobbit自体のインストールとなる。公式サイトでは Red Hat Enterprise Linux 4(CentOS 4)用のRPMがないし、SPECファイルにバグがあってRPMソースの再ビルドでは一部の設定ファイルがおかしくなってしまうので、TAR.GZファイルからコンパイルすることにした。

# curl -O http://jaist.dl.sourceforge.net/sourceforge/hobbitmon/hobbit-4.2.0.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2286k 100 2286k 0 0 3125k 0 --:--:-- --:--:-- --:--:-- 6532k

ダウンロードしたTAR.GZファイルを解凍し、解凍先のディレクトリに移動する。そしてconfigureを実行しよう。

# tar zxf hobbit-4.2.0.tar.gz # cd hobbit-4.2.0 # ./configure

fpingを利用するか聞かれるのでYを入力しよう。

Configuration script for Hobbit This script asks a few questions and builds a Makefile to compile Hobbit Checking your make-utility Checking pre-requisites for building Hobbit Checking for fping ... Hobbit has a built-in ping utility (hobbitping) However, it is not yet fully stable and therefore it may be best to use the external fping utility instead. I found fping in /usr/sbin/fping Do you want to use it [Y/n] ? Y Checking to see if '/usr/sbin/fping 127.0.0.1' works ... 127.0.0.1 is alive OK, will use '/usr/sbin/fping' for ping tests NOTE: If you are using an suid-root wrapper, make sure the 'hobbit' user is also allowed to run fping without having to enter passwords. For 'sudo', add something like this to your 'sudoers' file: hobbit: ALL=(ALL) NOPASSWD: /usr/local/sbin/fping

RRDtoolとPCREのライブラリの確認のあと、SSL系のサービスの利用可否を訪ねられる。利用することが推奨されているし、とりあえずyでいいだろう。

Checking for RRDtool ... test-rrd.c: In function `main': test-rrd.c:30: error: 関数 `rrd_graph' への引数が少なすぎます make: *** [test-compile] エラー 1 Not RRDtool 1.0.x, checking for 1.2.x Found RRDtool include files in /usr/include Found RRDtool libraries in /usr/lib Checking for PCRE ... Found PCRE include files in /usr/include/pcre Found PCRE libraries in /usr/lib Checking for OpenSSL ... Found OpenSSL include files in /usr/include Found OpenSSL libraries in /usr/lib Hobbit can use the OpenSSL library to test SSL-enabled services like POP3S, IMAPS, NNTPS and TELNETS. If you have the OpenSSL library installed, I recommend that you enable this. Do you want to be able to test SSL-enabled services (y) ? y

LDAPとLDAP/SSLサービスの利用可否を訪ねられる。とりあえずyでいいだろう。

Checking for LDAP ... Found LDAP include files in /usr/include Found LDAP libraries in /usr/lib Hobbit can use your OpenLDAP LDAP client library to test LDAP servers. Do you want to be able to test LDAP servers (y) ? y Enable experimental support for LDAP/SSL (OpenLDAP 2.x only) (y) ? y

ラージ・ファイルのサポートの確認のあと、Hobbitを実行するユーザー名が確認される。事前に作成しておいたhobbitがデフォルトなので、そのままで良いだろう。

Checking for Large File Support ... Large File Support OK Setting up for a Hobbit server What userid will be running Hobbit [hobbit] ? [Enter] Found passwd entry for user hobbit:x:504:504:Hobbit Administrator:/home/hobbit:/bin/bash

Hobbitのインストール先だ。ボクは/opt/hobbitに変更したが、デフォルトのままでも良いだろう。

Where do you want the Hobbit installation [/home/hobbit] ? /opt/hobbit WARNING: /opt/hobbit does not exist.

Webの設定に移る。HobbitのWebページにアクセスする際のURLパス、CGIのインストール先、CGIのURLパス、管理用CGIのインストール先、管理用CGIのURLパスを設定する。管理用CGIからは管理マシンのオン/オフが設定できるため、のちほどBASIC認証をかけるが、とりあえずパスはデフォルトのままで良いだろう。これらの設定はApache設定ファイルとしてinstall_dir/server/etc/hobbit-apache.confに反映される。

What URL will you use for the Hobbit webpages [/hobbit] ? [Enter] Where to put the Hobbit CGI scripts [/opt/hobbit/cgi-bin] ? (Note: This is the filesystem directory - we will get to the URL shortly) [Enter] What is the URL for the Hobbit CGI directory [/hobbit-cgi] ? (Note: This is the URL - NOT the filesystem directory) [Enter] ********************** SECURITY NOTICE **************************** If your Hobbit server is accessible by outsiders, then you should restrict access to the CGI scripts that handle enable/disable of hosts, and acknowledging of alerts. The easiest way to do this is to put these in a separate CGI directory and require a password to access them. Even if your Hobbit server is on a secured, internal network, you may want to have some operations (like disabling a host) be password- protected - that lets you see who disabled or acknowledged an alert. Where to put the Hobbit Administration CGI scripts [/opt/hobbit/cgi-secure] ? (Note: This is the filesystem directory - we will get to the URL shortly) [Enter] What is the URL for the Hobbit Administration CGI directory [/hobbit-seccgi] ? (Note: This is the URL - NOT the filesystem directory) [Enter] ** Note that you may need to modify your webserver configuration. ** After installing, see /opt/hobbit/server/etc/hobbit-apache.conf for an example configuration.

Apacheの実行グループ名を指定する。CentOSの場合はapacheだ。

To generate Hobbit availability reports, your webserver must have write-access to a directory below the Hobbit top-level directory. I can set this up if you tell me what group-ID your webserver runs with. This is typically 'nobody' or 'apache' or 'www-data' If you dont know, just hit ENTER and we will handle it later. What group-ID does your webserver use ? apache

ログの保存場所を聞かれる。ボクは/var/opt/hobbit/logに変更したが、デフォルトのままでも良いだろう。

Where to put the Hobbit logfiles [/var/log/hobbit] ? /var/opt/hobbit/log

ホスト名とIPアドレスを入力する。IPアドレスは127.0.0.1がデフォルトになっているが、必ず127.0.0.1以外の割り当てられたIPアドレスを指定しよう。

What is the name of this host [oscar] ? oscar What is the IP-address of this host [127.0.0.1] ? 192.168.0.100

マニュアルのインストール先を設定したらconfigureは完了だ。ボクは/var/opt/hobbit/logに変更したが、デフォルトのままでも良いだろう。

Where should I install the Hobbit man-pages (/usr/local/man) ? /opt/hobbit/man Using Linux Makefile settings Created Makefile with the necessary information to build Hobbit Some defaults are used, so do look at the Makefile before continuing. Configuration complete - now run make (GNU make) to build the tools

次にmakeになるのだが、その前にボクはMakefile内の、取得したデータやHTMLファイルを保存するBBVAR install_dir/dataから/var/opt/hobbitに変更した。気にならないのであれば気にする必要はない。

# sed -i 's!^BBVAR.*$!BBVAR = /var/opt/hobbit!' Makefile

makeしよう。

# make MAKE="make" CC="gcc" CFLAGS="-g -O2 -Wall -Wno-unused -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DLINUX -I. -I`pwd`/include -I/usr/include/pcre" LDFLAGS="" `pwd`/build/genconfig.sh Checking for socklen_t Checking for snprintf ...... cat clientlaunch.cfg.DIST | sed -e 's!@CLIENTFLAGS@!!g' >clientlaunch.cfg make[1]: Leaving directory `/root/Desktop/hobbit-4.2.0/client' Build complete. Now run 'make install' as root

make install しよう。

# make install mkdir -p /opt/hobbit/server /opt/hobbit/server/download /var/opt/hobbit mkdir -p /opt/hobbit/server/bin chown hobbit /opt/hobbit/server/bin ...... chown -R hobbit /opt/hobbit/client make[1]: Leaving directory `/root/Desktop/hobbit-4.2.0/client' Installation complete. You must configure your webserver for the Hobbit webpages and CGI-scripts. A sample Apache configuration is in /opt/hobbit/server/etc/hobbit-apache.conf If you have your Administration CGI scripts in a separate directory, then you must also setup the password-file with the htpasswd command. To start Hobbit, as the hobbit user run '/opt/hobbit/server/bin/hobbit.sh start' To view the Hobbit webpages, go to http://oscar/hobbit

つづいて、いくつかの細かい設定も行っておこう。まずはアクセスしやすいようにHobbitの構成ファイルへのシンボリック・リンクを/etcに作ろう。

# ln -s /opt/hobbit/server/etc /etc/opt/hobbit

Apache構成ファイルをコピーし、Apacheにをそれを読み込ませる。

# cp /etc/opt/hobbit/hobbit-apache.conf /etc/httpd/conf.d/hobbit.conf # service httpd reload httpd を再読み込み中: [ OK ]

管理用CGIにはBASIC認証が行われるため、パスワードを設定しよう。

# htpasswd -c /etc/opt/hobbit/hobbitpasswd gadget New password: Re-type new password: Adding password for user gadget

マシン起動時にHobbitも自動起動させる起動スクリプトを編集し、HobbitのログをローテーションさせるLogrotateの設定ファイルとそれぞれコピーしておこう。これらはTAR.GZの解凍先のrpmディレクトリ内にある。

# chown root:root rpm/* # chmod 644 rpm/* # sed -i 's!^DAEMON=.*$!DAEMON=/opt/hobbit/server/bin/hobbit.sh!' rpm/hobbit-init.d # cp rpm/hobbit-init.d /etc/init.d/hobbit # chmod 755 /etc/init.d/hobbit # chkconfig hobbit on # sed -i 's!/var/log/hobbit!/var/opt/hobbit/log!' rpm/hobbit.logrotate # cp rpm/hobbit.logrotate /etc/logrotate.d/hobbit

起動スクリプトがあれば、hobbitユーザーでinstall_dir/server/bin/hobbit.shを実行しなくても、serviceから起動できる。

# service hobbit start Starting hobbit: Hobbit started hobbit.

http://hostname/hobbit/にアクセスしてlocalhostの監視が始まっていればサーバーは問題なく動作している。起動直後はbbgenが黄色いアイコンになっているが正しい動作であり、5分もすると緑のアイコンになる。もし赤いアイコンが出ていたらそれをクリックして原因を突き止めよう。白いアイコンは「監視対象が設定されていない」なので、とりあえずは問題ない。なお、この時点でローカルのリソース監視なども始まっているので、trendsアイコンを一時間後くらいにクリックしたりするとちょっとおもしろい。

Hobbit

2 Trackbacks

Hobbitクライアント インストール

Hobbit Monitor Hobbitサーバーのインストールに続いてHobbitクライアントのインストール方法を説明しよう。HobbitはUnix系OSならどれでも利用できる...

From : 複眼中心 @ 2007-09-22 11:45:43

Hobbitを設定

Hobbit Monitor K-blo: Hobbit HobbitサーバーのインストールとHobbitクライアントのインストールが終わったら、いよいよ “なにを監視して...

From : 複眼中心 @ 2007-09-22 11:46:15

Track from Your Website

http://rewse.jp/fukugan/trackback/tb.php?id=839

3 Comments

Re: Hobbitサーバー インストール

CS Control 使うてくれ... (Cool)

From : あつ @ 2006-12-06 23:01:15 編集

Re: Hobbitサーバー インストール

ボクの給料では買えません……。

From : ガヂェット @ 2006-12-06 23:22:54 編集

Re: Hobbitサーバー インストール

クライアントからの送信がないとcpuやbbdなどが表示されません。TCP/1984をブロックしていないか確認してみてください。

From : rewse @ 2007-11-04 20:47:45 編集

Post Your Comment


(Smile) (Wink) (Laugh) (Foot in mouth) (Frown) (Gasp) (Cool) (Tongue)

*は入力必須です。E-Mailは公開されません。