1、添加用户
[root@nagios ~]# groupadd nagcmd [root@nagios ~]# useradd -G nagcmd nagios [root@nagios ~]# usermod -a -G nagcmd apache
2、安装nagios
官方下载地址:http://www.nagios.org/download/
[root@nagios ~]# cd /home/nagios [root@nagios nagios]# wget http://jaist.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.7/nagios-4.0.7.tar.gz [root@nagios nagios]# tar xzvf nagios-4.0.7.tar.gz [root@nagios nagios]# cd nagios-4.0.7 [root@nagios nagios-4.0.7]# ./configure --with-command-group=nagcmd --enable-event-broker [root@nagios nagios-4.0.7]#make all [root@nagios nagios-4.0.7]#make install [root@nagios nagios-4.0.7]#make install-init [root@nagios nagios-4.0.7]#make install-config [root@nagios nagios-4.0.7]#make install-commandmode [root@nagios nagios-4.0.7]#make install-webconf
设置登陆web界面时HTTP验证的账号密码
[root@nagios nagios-4.0.7]#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin [root@nagios nagios-4.0.7]#service httpd restart
3、安装nagios-plugins
[root@nagios nagios-4.0.7]#cd /home/nagios [root@nagios nagios]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.2.tar.gz [root@nagios nagios]# tar xzvf nagios-plugins-2.0.2.tar.gz [root@nagios nagios]# cd nagios-plugins-2.0.2 [root@nagios nagios-plugins-2.0.2]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql [root@nagios nagios-plugins-2.0.2]# make [root@nagios nagios-plugins-2.0.2]# make install
所有插件命令将被安装到/usr/local/nagios/libexec 目录下
4、其他设置
检查nagios的配置:
[root@nagios ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
添加自动动项:
[root@nagios ~]# chkconfig --add nagios [root@nagios ~]# chkconfig nagios on [root@nagios ~]# service nagios start
登陆页面:
http://localhost/nagios
账号nagiosadmin密码123456
5、遇到的问题
点击页面左侧的MAP和History报错:
The requested URL /nagios/sbin/statusmap.cgi was not found on this server.
The requested URL /nagios/sbin/histogram.cgi was not found on this server.
原因一:因为gd-devel php-gd没有安装的问题,造成NAGIOS在编译时不生成这statusmap.cgi
原因二:nagios编译在前, gd-devel安装在后,造成不生成这statusmap.cgi
解决方法:yum安装gd-devel php-gd,再重新编译安装nagios
转载于:https://blog.51cto.com/ywzhou/1531926