Nagiosインストール
——————————————————
yum -y install gd-devel
useradd -d /usr/local/nagios/ -M nagios
cd /usr/local/src
wget http://jaist.dl.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
tar zxvf nagios-3.2.0.tar.gz
cd nagios-3.2.0
wget http://ftp.momo-i.org/pub/other/nagios-jp-3.2.0.patch.gzgzip -d nagios-jp-3.2.0.patch.gz
patch -p1 < nagios-jp-3.2.0.patch
./configure
make all
make install
make install-init
make install-commandmode
make install-config
——————————————————
さざなみフォントインストール
——————————————————
wget http://osdn.dl.sourceforge.jp/efont/10087/sazanami-20040629.tar.bz2
tar jxvf sazanami-20040629.tar.bz2
mkdir /usr/local/nagios/etc/fontcp sazanami-20040629/sazanami-gothic.ttf /usr/local/nagios/etc/font/font.ttf
——————————————————
Nagiosプラグインインストール
——————————————————
yum –enablerepo=remi,epel,rpmforge install mysql-devel
wget http://jaist.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
tar zxvf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
./configure && make && make install
cp contrib/check_mem.pl /usr/local/nagios/libexec/設定の編集
vi /usr/local/nagios/libexec/check_mem.pl$command_line = `vmstat | tail -1 | awk ‘{print \$4,\$5}’`;
↓
$command_line = `free | head -3 | tail -1 | awk ‘{print \$3,\$4}’`;chmod +x /usr/local/nagios/libexec/check_mem.pl
Nagios設定
——————————————————
vi /usr/local/nagios/etc/nagios.cfg
——————————————————————————————
cfg_dir=/usr/local/nagios/etc/servers ← 行頭の#を削除してコメント解除(サーバー監視設定有効化)
date_format=iso8601 ← 日付書式をYYYY-MM-DD HH:MM:SSにする
——————————————————————————————
vi /usr/local/nagios/etc/cgi.cfg
ttf_file=/usr/local/nagios/etc/font/font.ttf
mkdir /usr/local/nagios/etc/servers
vi /usr/local/nagios/etc/objects/contacts.cfg
——————————————————————————————
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of useremail 管理者メールアドレス ← 管理者メールアドレスを指定
}
——————————————————————————————
vi /usr/local/nagios/etc/objects/localhost.cfg
——————————————————————————————
define service{
use local-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_ssh
notifications_enabled 1 ← 1を指定(SSH状態変化時に通知する)
}define service{
use local-service ; Name of service template to use
host_name localhost
service_description HTTP
check_command check_http
notifications_enabled 1 ← 1を指定(HTTP状態変化時に通知する)
}
——————————————————————————————
——————————————————————————————
vi /usr/local/nagios/etc/objects/commands.cfg ← commands.cfg編集
——————————————————————————————
# ‘notify-host-by-email’ command definition
define command{
command_name notify-host-by-email
# nkfコマンド追加(メール本文文字化け対処)
command_line /usr/bin/printf “%b” “***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/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
# nkfコマンド追加(メール本文文字化け対処)
command_line /usr/bin/printf “%b” “***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SERVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$” | /usr/bin/nkf -j | /bin/mail -s “** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}
——————————————————————————————
Apache設定
usermod -G nagios apache
vi /etc/httpd/conf.d/nagios.conf
———————————————————–
ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”
<Directory “/usr/local/nagios/sbin”>
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
# Allow from all
# Order deny,allow
# Deny from all
Allow from 127.0.0.1
Allow from 192.168.24.0/24
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>Alias /nagios “/usr/local/nagios/share”
<Directory “/usr/local/nagios/share”>
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
# Allow from all
# Order deny,allow
# Deny from all
Allow from 127.0.0.1
Allow from 192.168.24.0/24
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
———————————————————–
/etc/rc.d/init.d/httpd reload
htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
Nagios起動
/etc/rc.d/init.d/nagios start
/sbin/chkconfig –add nagios
/sbin/chkconfig nagios on
Nagios確認