系统版本
[root@localhost ~]# cat /etc/issue
CentOS release 6.9 (Final)
- Nagios主程序
https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.2/ - nagios-plugins-1.4.13.tar.gz Nagios 的插件
https://www.nagios.org/downloads/nagios-plugins/ - nrpe-2.12.tar.gz 代理检测程序
https://sourceforge.net/projects/nagios/files/nrpe-3.x/nrpe-3.2.0/
在此演示安装版本为nagios-4.3.2,nagios-plugins-2.2.1,nrpe-3.2.0(未安装)
一、nagios-4.3.2 安装
1.安装前的依赖检查
[root@localhost ~]# yum install httpd php gcc glibc glibc-common gd gd-devel
[root@localhost ~]# useradd -m nagios
[root@localhost ~]# groupadd nagcmd
[root@localhost ~]# usermod -a -G nagcmd nagios
[root@localhost ~]# usermod -a -G nagcmd apache
2.解压
[root@localhost ~]# cd usr/local/src/
[root@localhost src]# tar xvf nagios-4.3.2.tar.gz
[root@localhost src]# cd nagios-4.3.2
3.安装
[root@localhost nagios-4.3.2]# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --with-nagios-user=nagios --with-nagios-group=Nagios
[root@localhost nagios-4.3.2]# make all
[root@localhost nagios-4.3.2]# make install
[root@localhost nagios-4.3.2]# make install-init (生成init启动脚本)
[root@localhost nagios-4.3.2]# make install-config (生成一些模板配置文件)
[root@localhost nagios-4.3.2]# make install-commandmode (设置相应的权限)
[root@localhost nagios-4.3.2]# make install-webconf (生成Apache配置文件nagios.conf)
4.为Nagios设置Web验证的密码。(注意第一次添加用户用-c选项,以后再添加千万别在用这个选项了,会覆盖以前的所有用户的。)
[root@localhost nagios-4.3.2]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
5.设置nagios的开机启动
[root@localhost nagios-4.3.2]# chkconfig --add nagios
[root@localhost nagios-4.3.2]# chkconfig nagios on
[root@localhost nagios-4.3.2]# chkconfig httpd on
6.关闭SELinux
[root@localhost nagios-4.3.2]# vi /etc/sysconfig/selinux
SELINUX=disabled
二、安装Nagios的插件nagios-plugin
[root@localhost src]# pwd
/usr/local/src
[root@localhost src]# tar xvf nagios-plugins-2.2.1.tar.gz
[root@localhost src]# cd nagios-plugins-2.2.1
[root@localhost nagios-plugins-2.2.1]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=Nagios
[root@localhost nagios-plugins-2.2.1]# make && make install
三、验证Nagios的样例配置文件
[root@localhost nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.3.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2017-05-09
License: GPL
Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
如果没有报错,可以启动Nagios服务
service nagios start
使用http://localhost/nagios/来访问
ps:如果遇到问题!!!!
如果遇到关于cgi什么权限问题!察看下/usr/local/nagios的属主组权限,
包括里面的内容,
尤其是/usr/local/nagios/etc/htpasswd.users这个文件的权限!都应该是nagios:nagios
另外尝试编辑
vi /usr/local/nagios/etc/cgi.cfg
把
use_authentication=1
修改为
use_authentication=0