在CentOS 6.4中使用yum安装Nagios-3.5.0

时间:2019-08-20 17:58:26  来源:igfitidea点击:

在系统中下载EPEL存储库

yum install wget (use this command if you do not find wget command in your system)
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

或者

直接安装epel repo rpm。

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

在系统中安装nagios3.5.0及其依赖项

yum install nagios nagios-devel nagios-plugins* gd gd-devel httpd php gcc glibc glibc-common openssl

为nagiosadmin用户设置密码

htpasswd -c /etc/nagios/passwd nagiosadmin
 G1veAlphanumericPassword

默认用户为nagiosadmin,密码也为nagiosadmin

nagiosadmin 用户是在/etc/nagios/cgi.cfg中指定的。

vi /etc/nagios/cgi.cfg
# AUTHENTICATION USAGE
use_authentication=1
# SYSTEM/PROCESS INFORMATION ACCESS
authorized_for_system_information=nagiosadmin
# CONFIGURATION INFORMATION ACCESS
authorized_for_configuration_information=nagiosadmin
# SYSTEM/PROCESS COMMAND ACCESS
authorized_for_system_commands=nagiosadmin
# GLOBAL HOST/SERVICE VIEW ACCESS
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
# GLOBAL HOST/SERVICE COMMAND ACCESS
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin

/etc/http/conf.d/nagios.conf中定义了认证的方法:

cat /etc/http/conf.d/nagios.conf
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.
ScriptAlias /nagios/cgi-bin/ "/usr/lib/nagios/cgi-bin/"
<Directory "/usr/lib/nagios/cgi-bin/">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/passwd
Require valid-user
</Directory>
Alias /nagios "/usr/share/nagios/html"
<Directory "/usr/share/nagios/html">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/passwd
Require valid-user
</Directory>

启动httpd和nagios

/etc/init.d/httpd start
/etc/init.d/nagios start

测试

打开 http://服务器ip/nagios访问nagios服务器测试。