参考

■gdのインストール

[root@localhost src]# yum -y install gd gd-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
* addons: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
Setting up Install Process
Parsing package install arguments
Package gd-2.0.33-9.4.el5_1.1.i386 already installed and latest version
Package gd-devel-2.0.33-9.4.el5_1.1.i386 already installed and latest version
Nothing to do


■ユーザー作成 nagios:******
[root@localhost src]# useradd -m nagios
[root@localhost src]# passwd nagios
Changing password for user nagios.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.


■グループ作成
[root@localhost src]# groupadd nagcmd

■グループにユーザ追加
[root@localhost src]# usermod -a -G nagcmd nagios
[root@localhost src]# usermod -a -G nagcmd apache
[root@localhost src]# usermod -a -G nagcmd vivi


■ベーシック認証用のパスワードファイルを作成
[root@localhost src]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
(パスワードを聞かれるので入力をする。)


■nagios本体とプラグインをダウンロード
[root@localhost src]# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.0/nagios-3.2.0.tar.gz/d
ownload


[root@localhost src]# wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.14/nagios-plugins-1.4.14.t
ar.gz/download

[root@localhost src]# tar zxvf nagios-3.2.0.tar.gz

[root@localhost src]# cd nagios-3.2.0

■日本語化
[root@localhost nagios-3.2.0]# wget http://sourceforge.jp/projects/nagios-jp/downloads/38828/nagios-3.1.0-ja-utf8.pat
ch.gz/
★getできなかったので/tmpにローカルからコピー
[root@localhost nagios-3.2.0]# cp /tmp/nagios-3.1.0-ja-utf8.patch.gz .
★パッチを当てる
[root@localhost nagios-3.2.0]# gzip -dc nagios-3.1.0-ja-utf8.patch.gz |patch -p0


■インストール

[root@localhost nagios-3.2.0]# ./configure --with-command-group=nagcmd


[root@localhost nagios-3.2.0]# make all
・・・・・
make install
- This installs the main program, CGIs, and HTML files

make install-init
- This installs the init script in /etc/rc.d/init.d

make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file

make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!

make install-webconf
- This installs the Apache config file for the Nagios
web interface

[root@localhost nagios-3.2.0]# make install
[root@localhost nagios-3.2.0]# make install-init
[root@localhost nagios-3.2.0]# make install-commandmode
[root@localhost nagios-3.2.0]# make install-config
[root@localhost nagios-3.2.0]# make install-webconf

■さざなみフォント(日本語化に必要)
[root@localhost nagios-3.2.0]# tar jxvf /tmp/sazanami-20040629.tar.bz2
★FONTディレクトリを作成
[root@localhost nagios-3.2.0]# mkdir /usr/local/nagios/etc/font
★フォントをコピー
[root@localhost nagios-3.2.0]# cp sazanami-20040629/sazanami-gothic.ttf /usr/local/nagios/etc/font/font.ttf


■プラグインのインストール

[root@localhost nagios-3.2.0]# cd ../
[root@localhost src]# tar zxvf nagios-plugins-1.4.14.tar.gz
[root@localhost src]# cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@localhost nagios-plugins-1.4.14]# make
・・・
dynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lmygcc -lpthread -ldl
gcc -I/usr/include/mysql -g -pipe -m32 -DNP_VERSION=\"1.4.14\" -g -O2 -o check_mysql check_mysql-check_mysql.o netutils.o utils.o -rdynamic -L/usr/local/src/nagios-plugins-1.4.14/plugins ../lib/libnagiosplug.a ../gl/libgnu.a -lresolv -L/usr/lib/mysql /usr/lib/mysql/libmysqlclient.so /usr/lib/mysql/libz.a -lcrypt -lnsl -lm -lmygcc -lpthread -ldl -Wl,--rpath -Wl,/usr/lib/mysql -Wl,--rpath -Wl,/usr/lib/mysql
gcc: /usr/lib/mysql/libmysqlclient.so: No such file or directory
make[2]: *** [check_mysql] エラー 1
make[2]: ディレクトリ `/usr/local/src/nagios-plugins-1.4.14/plugins' から出ます
make[1]: *** [all-recursive] エラー 1
make[1]: ディレクトリ `/usr/local/src/nagios-plugins-1.4.14' から出ます
make: *** [all] エラー 2

★mysqlのlibmysqlclient.soがないと怒られる。
⇒参考 http://plaza.rakuten.co.jp/gontata/diary/200904130000/

はまったことその3
現象:tritonn(MySQL)をrpmからインストールした場合に、PHPのmakeが失敗する。
「/usr/lib64/mysql/libmysqlclient.so」が見つからないというエラー。

解決方法:シンボリックリンクを張る
ln -s /usr/lib64/libmysqlclient.so.15.0.0 /usr/lib64/mysql/libmysqlclient.so
ln -s /usr/lib64/libmysqlclient_r.so.15.0.0 /usr/lib64/mysql/libmysqlclient_r.so

★tritonのせいらしい。
■参考にしてリンクをはる。
[root@localhost nagios-plugins-1.4.14]# ln -s /usr/lib/libmysqlclient.so.15.0.0 /usr/lib/mysql/libmysqlclient.so
[root@localhost nagios-plugins-1.4.14]# ln -s /usr/lib/libmysqlclient_r.so.15.0.0 /usr/lib/mysql/libmysqlclient_r.so


■再度make

[root@localhost nagios-plugins-1.4.14]# make
[root@localhost nagios-plugins-1.4.14]# make install


■確認
[root@localhost nagios-plugins-1.4.14]# ls /usr/local/nagios/libexec/
check_apt check_dummy check_ircd check_mysql_query check_overcr check_spop negate
check_breeze check_file_age check_jabber check_nagios check_pgsql check_ssh urlize
check_by_ssh check_flexlm check_ldap check_nntp check_ping check_ssmtp utils.pm
check_clamd check_ftp check_ldaps check_nntps check_pop check_swap utils.sh
check_cluster check_http check_load check_nt check_procs check_tcp
check_dhcp check_icmp check_log check_ntp check_real check_time
check_dig check_ide_smart check_mailq check_ntp_peer check_rpc check_udp
check_disk check_ifoperstatus check_mrtg check_ntp_time check_sensors check_ups
check_disk_smb check_ifstatus check_mrtgtraf check_nwstat check_simap check_users
check_dns check_imap check_mysql check_oracle check_smtp check_wave


■メモリチェックプラグインインストール http://centossrv.com/nagios.shtml
[root@localhost nagios-plugins-1.4.14]# vi /usr/local/nagios/etc/nagios.cfg

cfg_dir=/usr/local/nagios/etc/servers ★コメントアウト
date_format=iso8601

■設定ファイル編集 http://centossrv.com/nagios.shtml
cfg_dir=/usr/local/nagios/etc/servers ★コメントアウト
date_format=iso8601


■cgi.cfg編集 http://centossrv.com/nagios.shtml
[root@localhost nagios-plugins-1.4.14]# vi /usr/local/nagios/etc/cgi.cfg
ttf_file=/usr/local/nagios/etc/font/font.ttf ★コメントアウト


■ サーバー監視設定ファイル格納ディレクトリ作成 http://centossrv.com/nagios.shtml
[root@localhost nagios-plugins-1.4.14]# mkdir /usr/local/nagios/etc/servers


■contacts.cfg編集
email ****@gmail.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******


■commands.cfg編集 http://centossrv.com/nagios.shtml

★| /usr/bin/nkf -j を追記
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOS
TNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/nkf
-j
| /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService:
$SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAddi
tional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/nkf -j | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$
SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$


■apache設定
★とくになし
★会社では、 http://centossrv.com/nagios.shtmlを参考がよいかも


■構文チェック

[root@localhost nagios-plugins-1.4.14]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check



■apache再起動

■起動設定
[root@localhost nagios-plugins-1.4.14]# /etc/init.d/nagios start
Starting nagios: done.
[root@localhost nagios-plugins-1.4.14]# chkconfig --add nagios
[root@localhost nagios-plugins-1.4.14]# chkconfig nagios on


■アクセス

http://アドレス/nagios/

ユーザ:nagiosadmin
パス:■ベーシック認証用のパスワードで設定したもの(limixweb)