- 安装nagios前提
关闭selinux:
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
下载各类安装包:
yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
- 安装nagios
下载解压安装包:
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.1.tar.gz
tar -zxvf nagios-4.2.1.tar.gz
cd nagios-4.2.1
编译:
cd /tmp/nagioscore-nagios-4.4.1/
./configure
make all
*** Configuration summary for nagios 4.2.1 09-06-2016 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /usr/bin/mail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /usr/bin/traceroute
二.创建用户
创建用户名:/usr/sbin/useradd -m nagios
创建用户组:
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
添加用户名和Apache到该组:
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
删除用户名:userdel -rf name
查看用户名:ls –l /home
三.编译配置文件
make install
make install-daemoninit
systemctl enable httpd.service
make install-commandmode
make install-config
四.安装Apache配置文件
make install-webconf
五.设置web浏览器访问端口
firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --add-port=80/tcp --permanent
在此之前,先开启防火墙:
Systemctl start firewall.service
六.设置web登录账号
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
七.开启Apache服务和nagios服务
systemctl start httpd.service
systemctl start nagios.service
八.测试
在浏览器中输入网址:http://xxx.xx.xx.xx(本地网址)/nagios
小问题之一:
无法开启nagios服务,找不到nagios目录下的etc目录,无法创建config文件?
解决:
在nagios-4.2.1目录下,编译make install-config
小问题之二:
Web页面无法访问?
解决:
原因是没有设置登录用户以及密码,所以命令
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
(也是修改用户名和密码的命令)
十.完成安装主体进程
参考借鉴:
https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source-96.html#CentOS
https://blog.csdn.net/firstar521/article/details/52848393