×

扫描二维码登录本站

QQ登录

只需一步,快速开始

Nagios的安装与配置(2)

标签: 暂无标签
本帖最后由 monicazhang 于 2015-10-30 21:41 编辑

20151030淡然
续上







   } 添加小太阳模版,镶嵌在nagios页面上。#vi /usr/local/nagios/etc/objects/templates.cfg## 在最后添加define host {name       host-pnpaction_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_register   0}define service {name       srv-pnpaction_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$register   0} 最后在hosts.cfg和services.cfg中调用host-pnp和srv-pnp模板#vi hosts.cfgdefine host {        use                     host-pnp        host_name               nagios-test1        alias                   nagios test1        address                 172.26.188.202        contact_groups          admins        check_command           check-host-alive        max_check_attempts      5        notification_interval   10        notification_period     24x7        notification_options    d,u,r        }#vi services.cfgdefine service {        use                   srv-pnp        host_name             nagios-test1        service_description   check_tcp 80        check_period          24x7        max_check_attempts    4        normal_check_interval 3        retry_check_interval  2        contact_groups        admins        notification_interval   10        notification_period     24x7        notification_options    w,u,c,r        event_handler_enabled   1        event_handler           restart-httpd        check_command      check_tcp!80     
   }Nagios的配置配置apache
#vi/etc/httpd/conf/httpd.conf
找到:ServerName www.example.com:80                               nagios安装
修改为:
ServerName 172.26.188.201
找到:
User nobody
Group #-1
修改为:
User nagios
Group nagios
找到:
DirectoryIndex index.html index.html.var
修改为
DirectoryIndex index.html index.php
接着增加如下内容:
AddType application/x-httpd-php .php


为了安全其间,一般情况下要让nagios的web监控界面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf文件最后添加如下信息:
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"                          开源监控软件
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd                         nagios配置
Require valid-user
</Directory>




创建
apache目录验证文件
在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:
# htpasswd -c /usr/local/nagios/etc/htpasswd ixdba
New password: (输入密码)
Re-type new password: (再输入一次密码)
Adding password for user ixdba
这样就在/usr/local/nagios/etc目录下创建了一个htpasswd验证文件,当通过http://ip/nagios/访问时就需要输入用户名和密码了。


配置nagios
修改cgi.cfg
refresh_rate=30                                         #nagios主页的刷新时间,我设置成30秒自动刷新
use_authentication=1                                    #开启认证功能
default_user_name=ixdba                                 


修改
nagios.cfg
去掉以下注释,没有的行添加上去:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg             #nagios可调用的监控命令
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg             #联系人配置
cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg        #联系人组配置
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg          #监控时间配置
cfg_file=/usr/local/nagios/etc/objects/templates.cfg            #模板配置
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg                #监控主机配置
cfg_file=/usr/local/nagios/etc/objects/services.cfg             #监控服务配置                         监控软件

check_external_commands=1                                       #允许web下重启nagios
command_check_interval=10s                                      #命令检查时间间隔


修改
commands.cfg
添加nrpe的定义:
# 'check_nrpe ' command definition
define command{
command_namecheck_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}


修改
contacts.cfg
添加联系人信息,内容如下:
define contact {
        contact_name    test1
        alias                system administrator
        service_notification_period    24x7
        host_notification_period       24x7
        service_notification_options   w,u,c,r
        host_notification_options       d,u,r
        service_notification_commands  notify-service-by-email
        host_notification_commands     notify-host-by-email
        email                          test1@test.com                                 nagios实施
        }


修改
contactgroups.cfg
添加联系人组信息,内容如下:
define contactgroup {
        contactgroup_name    admins
        alias                system administrator group
        members              test1
}







添加被监控机监控机配置
首先/usr/local/nagios/libexec/check_nrpe -H $被监控主机ip
应该都能输出 NRPE 的版本: NRPE v2.13
nagios的全部配置文件在:/usr/local/nagios/etc目录下面                         nagios培训


修改
hosts.cfg
hosts.cfg定义被监控机的主机信息,配置如下:




待续:http://www.itilxf.com/thread-53044-1-1.html
本帖关键字:Nagios




上一篇:Nagios的安装与配置(1)
下一篇:Nagios的安装与配置(3)
monicazhang

写了 2297 篇文章,拥有财富 12859,被 21 人关注

您需要登录后才可以回帖 登录 | 立即注册
B Color Link Quote Code Smilies

成为第一个吐槽的人

手机版|小黑屋|最新100贴|论坛版块|ITIL先锋论坛 |粤ICP备11099876号|网站地图
Powered by Discuz! X3.4 Licensed  © 2001-2017 Comsenz Inc.
返回顶部