#安装依赖包,添加nagios运行所需要的用户和组
sudo yum -y install httpd gcc glibc glibc-common gd gd-devel perl-devel perl-TimeDate
sudo /usr/sbin/useradd -m nagios
sudo /usr/sbin/groupadd nagcmd
sudo /usr/sbin/usermod -a -G nagcmd nagios
sudo /usr/sbin/usermod -a -G nagcmd apache
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
#安装nagios核心组件,注意指定command-group用户组
tar -zxvf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure --with-command-group=nagcmd --prefix=/usr/local/nagios --with-httpd-conf=/usr/local/apache2/conf
make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
sudo make install-webconf
#安装nagios-plugins插件
cd ..
tar –zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15.tar.gz
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install
#修改email为你的EMAIL地址
sudo vim /usr/local/nagios/etc/objects/contacts.cfg
#增加nagiosadmin用户并设置密码
sudo htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#复制nagios.conf中的内容到httpd.conf中,放在httpd.conf最后
cd /usr/local/apache2/conf
sudo chkconfig --add nagios
sudo chkconfig --level 35 nagios on
#测试nagios配置是否正确
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
sudo service nagios restart
sudo killall httpd
/usr/local/apache/bin/apachectl –k start
查看http://192.168.220.132/nagios/ 显示正常,收工!