黑帽联盟

标题: nagios安装配置(定位原创) [打印本页]

作者: 定位    时间: 2016-11-26 17:26
标题: nagios安装配置(定位原创)
以下是个人亲测过,可行。对nagios不懂的,百度一下吧

nagios的安装配置

服务端(监控端)配置

准备nagios程序和nagios所需要的插件程序,即nagios-4.0.7.tar.gz和nagios-plugins-2.0.3.tar.gz,这里我提供最新的版本

安装开发程序和环境:
yum groupinstall “Development Tools” “Development Libraries”

这里http和php,还有gd、gd-devel我已经编译安装好了,就不需要了yum安装了
直接:yum install gcc glibc glibc-common openssl-devel
如果没有安装直接yum即可

添加相应的用户和组
groupadd nagcmd
useradd -G nagcmd nagios
usermod -a -G nagcmd apache

安装顺序:先安装nagios自身,在安装插件程序

tar xf nagios-4.0.7.tar.gz
cd nagios-4.0.7
./configure --prefix=/service/nagios --datadir=/service/apache2.2/htdocs/nagios --sysconfdir=/service/nagios/etc --with-gd-lib=/service/common/gd2/lib --with-gd-inc=/service/common/gd2/include --with-command-group=nagcmd --enable-event-broker
make all
make install
make install-init
make install-commandmode   (安装nagios相关命令)
make install-config        (安装配置nagios文件)
make install-webconf        (安装web接口,供访问nagios程序)

tar xf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --prefix=/service/nagios --datadir=/service/apache2.2/htdocs/nagios --sysconfdir=/service/nagios/etc --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

为了安全起见,给web程序启用用户访问认证。
htpasswd -c /service/nagios/etc/htpasswd.users nagiosadmin

在虚拟机配置文件里添加认证代码
<VirtualHost 192.168.10.129:80>
#    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/service/apache2.2/htdocs/nagios"
    ServerName www.cnblackhat.com
#    ServerAlias www.dummy-host.example.com
#    ErrorLog "logs/dummy-host.example.com-error_log"
#    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

以下程序代码是在安装nagios程序时,执行make install-webconf生产的配置文件,即/etc/httpd/conf.d/nagios.conf,提供web接口,访问nagios程序
ScriptAlias /nagios/cgi-bin "/service/nagios/sbin"

<Directory "/service/nagios/sbin">
#  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 /service/nagios/etc/nagios.users
   Require valid-user
</Directory>

Alias /nagios "/service/apache2.2/htdocs/nagios"

<Directory "/service/apache2.2/htdocs/nagios">
#  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 /service/nagios/etc/nagios.users
   Require valid-user
</Directory>


service httpd start
service nagios start





欢迎光临 黑帽联盟 (https://bbs.cnblackhat.com/) Powered by Discuz! X2.5