自宅がiDC?

自宅がiDC?

自宅に普通のPCを置いてレンタルサーバ?いえ、iDCです。

自宅がiDC? RSS Feed
 
 
 
 

hobbit-4.2を監視サーバへインストール

このエントリをはてなブックマークに追加このエントリをdel.icio.usに追加このエントリをLivedoor Clipに追加このエントリをYahoo!ブックマークに追加このエントリをFC2ブックマークに追加このエントリをNifty Clipに追加このエントリをPOOKMARK. Airlinesに追加このエントリをBuzzurl(バザール)に追加このエントリをChoixに追加このエントリをnewsingに追加

昨日atom機を構築したので早速hobbitを導入して監視サーバを構築した。

日本語サイトで一番詳しいのはここかな↓
http://www.umasugi.com/~h070017/hobbit/index.html

hobbitは簡単に言うとサーバの死活監視を行うオープンソースのツールです。
サバクラ型で監視対象にもクライアントを入れなきゃいけない手間はあるけど
死活監視と同時にリソース監視もできる優れものです。
国内だとやっぱり圧倒的なシェアを誇るZABBIXが有名ですが、あれほどグラフィカルなUIがいらなくて
シンプルがいいならhobbitはうってつけなツールだったりします。

さて、早速インストールにとりかかるわけですが、まずはサーバから。
hobbitの動作に必要なパッケージは以下のものになります。
* fping
* httpdなどのWebサーバー
* openldap-devel
* openssl-devel
* pcre-devel
* rrdtool-devel
* rrdtool

パッケージ以外には
* pcre-7.8
も必要になります。これはソースからインストールします。

この辺はyumでさくっと入れてしまいましょう。
なのですが、rrdtoolは標準のリポジトリじゃ取得できませんので
以下のリポジトリを追加。

リポジトリの追加
# vi /etc/yum.repos.d/dag.repo
——————————————————————————-
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://ftp.riken.go.jp/pub/Linux/dag/RPM-GPG-KEY.dag.txt
enabled=1

——————————————————————————-

追加したら早速yumを実行。
# yum install fping rrdtool-devel rrdtool -y

pcre-7.8をhobbitの前にインストールします。
# cd /usr/local/src && \
wget http://downloads.sourceforge.net/pcre/pcre-7.8.tar.gz?use_mirror=jaist && \
tar zxvf pcre-7.8.tar.gz && \
chown -R root:root pcre-7.8* && \
cd pcre-7.8 && \
./configure --prefix=/opt/pcre-7.8 --enable-utf8 && \
make && make check && make install; echo "EXIT: $?"

正常にpcreがインストールできたら、次にhobbitを一気にインストールしちゃいます。
まずはhobbit用のユーザ作成
# groupadd -g 1000 hobbit \
&& useradd -u 1000 -g hobbit -s /sbin/nologin -d /home/hobbit hobbit

hobbitの本体をソースからインストール。インストール先は/opt/hobbitにしています。
# cd /usr/local/src && \
mkdir /opt/hobbit-4.2.0 && \
ln -s /opt/hobbit-4.2.0 /opt/hobbit && \
chgrp hobbit /usr/sbin/fping && \
chmod g+x /usr/sbin/fping && \
wget http://downloads.sourceforge.net/hobbitmon/hobbit-4.2.0.tar.gz?use_mirror=jaist && \
tar zxvf hobbit-4.2.0.tar.gz && \
chown -R hobbit:hobbit hobbit-4.2.0* && \
cd hobbit-4.2.0 &&
./configure --server\

※↑configureで”–server”オプションを忘れずに。

↓ここからは対話式になります。
———————————————–
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

Checking for RRDtool ...
test-rrd.c: In function ‘main’:
test-rrd.c:30: error: too few arguments to function ‘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 /opt/pcre-7.8/include
Found PCRE libraries in /opt/pcre-7.8/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) ?
n

Checking for LDAP ...
test-ldap.c: In function ‘main’:
test-ldap.c:16: 警告: implicit declaration of function ‘ldap_init’
test-ldap.c:16: 警告: assignment makes pointer from integer without a cast
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) ?
n

Checking for Large File Support ...
Large File Support OK

Setting up for a Hobbit server

What userid will be running Hobbit [hobbit] ?
hobbit
Found passwd entry for user hobbit:x:1000:1000::/home/hobbit:/sbin/nologin

Where do you want the Hobbit installation [/home/hobbit] ?
/opt/hobbit
OK, will configure to use /opt/hobbit as the Hobbit toplevel directory

What URL will you use for the Hobbit webpages [/hobbit] ?

Where to put the Hobbit CGI scripts [/opt/hobbit/cgi-bin] ?
(Note: This is the filesystem directory - we will get to the URL shortly)

What is the URL for the Hobbit CGI directory [/hobbit-cgi] ?
(Note: This is the URL - NOT the filesystem directory)

********************** 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)

What is the URL for the Hobbit Administration CGI directory [/hobbit-seccgi] ?
(Note: This is the URL - NOT the filesystem directory)

** Note that you may need to modify your webserver configuration.
** After installing, see /opt/hobbit/server/etc/hobbit-apache.conf for an example configuration.

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 ?
hobbit

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

What is the name of this host [x-labot] ?

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

** NOTE: Using 127.0.0.1 (loopback), but it is probably not what you want **

Where should I install the Hobbit man-pages (/usr/local/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します。
# make && make install && echo $?

次はapacheをインストールします。
hobbitサーバが収集したサーバの情報は、グラフィカルにrrdtoolを使って描画されるわけですが
このグラフィカルな画面を観たい場合はブラウザを通してみることになります。その時に必要なのがこのapacheなのです。

apacheのインストールは割愛します。ただ一点httpd.confに追記が必要なのは
include /opt/hobbit/server/etc/hobbit-apache.conf
こいつがないと監視のon,offができなかったりします。

とりあえず、デフォルトの設定のままhobbitを起動しましょう。
# /opt/hobbit/server/bin/hobbit.sh start
↑本当はhobbitユーザで起動するのですが、ping監視がうまくいかなかったので
起動スクリプトをいじって強制的にrootで起動。

そしてapacheも起動します。
# /opt/httpd_hobbit/bin/apachectl start

2つともエラーなく起動したら下記にアクセスしてみます。

http://[hostname]:port/hobbit/bb.html

怪しげなこんな画面が出てきたら成功です。(初期は赤下線しかありません)
e38394e382afe38381e383a3-21

アイコンがグリーンなら正常に動作していることを意味しています。
一番右のtrendアイコンをクリックすると時系列で描画されたグラフをできます。

監視は5分間隔で行われますが、いつまでたってもグラフが描画されない場合は
[hobbit-home]/server/etc/bb-hosts内や/etc/hostsファイルを疑いましょう。
管理人はここで当初はまった記憶があります。

で、格サーバにクライアントをインストールします。
ちょっと疲れたのでコマンドをざざっとw

>> hobbitインストールに必要なリポジトリを追加
# vi /etc/yum.repos.d/dag.repo
-------------------------------------------------------------------------------
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/x86_64/dag/
gpgcheck=1
gpgkey=http://ftp.riken.go.jp/pub/Linux/dag/RPM-GPG-KEY.dag.txt
enabled=1
-------------------------------------------------------------------------------

○必要なソフトウェア
* fping
* openldap-devel
* openssl-devel
* pcre-devel
* rrdtool-devel


# yum install -y fping rrdtool-devel gcc make

● Hobbitクライアントインストール
# mkdir /opt/hobbit-4.2.0 && ¥
ln -s /opt/hobbit-4.2.0 /opt/hobbit && ¥
cd /usr/local/src/ && ¥
wget http://surfnet.dl.sourceforge.net/sourceforge/pcre/pcre-6.3.tar.gz && ¥
tar zxvf pcre-6.3.tar.gz && ¥
chown -R root:root pcre-6.3* && ¥
cd pcre-6.3 && ¥
./configure --prefix=/opt/pcre-6.3 --enable-utf8 && ¥
make && make check && make install && ¥
ln -s /opt/pcre-6.3 /opt/pcre && ¥
cd /usr/local/src && ¥
wget http://jaist.dl.sourceforge.net/sourceforge/hobbitmon/hobbit-4.2.0.tar.gz && ¥
tar zxvf hobbit-4.2.0.tar.gz && ¥
chown -R hobbit:hobbit hobbit-4.2.0* && ¥
cd hobbit-4.2.0 && ¥
su -s /bin/bash -c "./configure --client" hobbit
---------------------------------------------------
Configuration script for Hobbit client

This script asks a few questions and builds a Makefile to compile Hobbit

Checking your make-utility

Hobbit normally keeps all of the client configuration files
on the Hobbit server. If you prefer, it is possible to use
a local client configuration file instead - if so, answer
'client' to the next question.
NB: Local configuration requires the PCRE libs on each host.

Server side client configuration, or client side [server] ?
server

※ここは注意が必要です。設定をserver側で一元的に行う場合はserverを指定しましょう。


Checking for Large File Support ...
Large File Support OK

What userid will be running Hobbit [hobbit] ?
hobbit
Found passwd entry for user hobbit:x:1002:1002::/home/hobbit:/bin/bash

Where do you want the Hobbit installation [/home/hobbit] ?
/opt/hobbit
OK, will configure to use /opt/hobbit as the Hobbit toplevel directory

What is the IP-address of your Hobbit server [127.0.0.1] ?
192.168.xxx.xxx

ここではhobbitのサーバを入れたホストのIPを指定。


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 && make install && echo $?

正常にインストールが完了したらhobbitのクライアントを起動します。
# /opt/hobbit/client/runclient.sh

最後にサーバ側の[hobbit_home]/server/etc/bb-hostsにクライアントのIPとホスト名を追記します。/etc/hostsにも追記しておきましょう。
hobbit-serverを再起動してしばらく待ちます。監視対象が表示されたら成功です。
おつかれさまでした。

詳しい設定項目など随時紹介できたらなと思いますが、最初の方に紹介したサイトが
かなりよくできているので参考にしてみてください。
次回は、httpのサービス監視を追加してサービスダウン時にアラートメールを送信する機能を紹介します。たぶん。

関連記事

3 Responses to “hobbit-4.2を監視サーバへインストール”

  1. 1
    tobayan:

    iDC運営できますな。

    あとはUPS(停電・雷対策)と空調・やな・・・

    電気代考えるとiDCにおいた方が安くなるよ
    勉強しますよw

  2. 2
    seiryu:

    いや運営してるからw
    iDC借りるならマウントできるように筐体作らなきゃだな。
    ってかまだまだ自宅のが安いなw

    こっちならビットアイルでかりちゃうよw

  3. 3
    監視サーバにアラート通知設定 | 自宅がiDC?:

    [...] 以前構築した監視サーバにやっとこさアラート通知設定を行いました。 [...]

Leave a Reply

Additional comments powered by BackType

TopHatenar

あわせて読みたいブログパーツ