首先是啦七八糟的依赖。web服务我不想折腾了,直接
yum install httpd php php-cli php-common libtool-ltdl fping perl-Digest-SHA1 perl-Socket6 perl-Crypt-DES perl-Digest-HMAC perl-Net-SNMP php-gd glibc glibc-common gd gd-devel gcc gcc-c++
创建用户和用户组
useradd nagios && passwd nagios
#若没创建组
groupadd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
apache是我的httpd运行的用户组,根据实际情况更换
到http://www.nagios.org/下载最新安装包
我下载的是nagios-3.2.3.tar.gz和nagios-plugins-1.4.15.tar.gz
tar zxvf nagios-3.2.3.tar.gz
cd nagios
./configure --with-nagios-user=nagios --with-command-group=nagcmd --enable-extra-opts --enable-libtap --with-openssl --with-mysql=/usr/bin/mysql_config --enable-perl-modules
然后根据提示
make install
make install-init
make install-config
make install-webconf
即可
编译安装plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
开机启动
chkconfig nagios on
点击map出现http 500 在安装了php-gd和ldconfig的前提下依然如此,查看日志:
error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
locate发现那个编译安装的lib在local里面,解决办法/etc/ld.so.conf添加一行
echo "/usr/local/lib/" >> /etc/ld.so.conf && ldconfig
创建http认证:
cd /usr/local/nagios/etc/
htpasswd htpasswd.users username
vim /usr/local/nagios/etc/cgi.cfg
修改
#莫要听网上瞎说改成0,保持1
use_authentication=1
#下面找到各个authorized_for*字段。添加刚才创建的http用户,多个用户逗号隔开
如果
../bin/nagios -v nagios.cfg
检查没问题的话就可以
service nagios start
service httpd restart
还只是开始,下面是要人命的配置