×

微信扫一扫,快捷登录!

Nagios的安装与配置(2)

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

20151030淡然
续上







}添加小太阳模版,镶嵌在nagios页面上。#vi/usr/local/nagios/etc/objects/templates.cfg##在最后添加definehost{namehost-pnpaction_url/pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_register0}defineservice{namesrv-pnpaction_url/pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$register0}最后在hosts.cfg和services.cfg中调用host-pnp和srv-pnp模板#vihosts.cfgdefinehost{usehost-pnphost_namenagios-test1aliasnagiostest1address172.26.188.202contact_groupsadminscheck_commandcheck-host-alivemax_check_attempts5notification_interval10notification_period24x7notification_optionsd,u,r}#viservices.cfgdefineservice{usesrv-pnphost_namenagios-test1service_descriptioncheck_tcp80check_period24x7max_check_attempts4normal_check_interval3retry_check_interval2contact_groupsadminsnotification_interval10notification_period24x7notification_optionsw,u,c,revent_handler_enabled1event_handlerrestart-httpdcheck_commandcheck_tcp!80
}Nagios的配置配置apache
#vi/etc/httpd/conf/httpd.conf
找到:ServerNamewww.example.com:80nagios安装
修改为:
ServerName172.26.188.201
找到:
Usernobody
Group#-1
修改为:
Usernagios
Groupnagios
找到:
DirectoryIndexindex.htmlindex.html.var
修改为
DirectoryIndexindex.htmlindex.php
接着增加如下内容:
AddTypeapplication/x-httpd-php.php


为了安全其间,一般情况下要让nagios的web监控界面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf文件最后添加如下信息:
#settingfornagios
ScriptAlias/nagios/cgi-bin"/usr/local/nagios/sbin"开源监控软件
<Directory"/usr/local/nagios/sbin">
AuthTypeBasic
OptionsExecCGI
AllowOverrideNone
Orderallow,deny
Allowfromall
AuthName"NagiosAccess"
AuthUserFile/usr/local/nagios/etc/htpasswd
Requirevalid-user
</Directory>
Alias/nagios"/usr/local/nagios/share"
<Directory"/usr/local/nagios/share">
AuthTypeBasic
OptionsNone
AllowOverrideNone
Orderallow,deny
Allowfromall
AuthName"nagiosAccess"
AuthUserFile/usr/local/nagios/etc/htpasswdnagios配置
Requirevalid-user
</Directory>




创建
apache目录验证文件
在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:
#htpasswd-c/usr/local/nagios/etc/htpasswdixdba
Newpassword:(输入密码)
Re-typenewpassword:(再输入一次密码)
Addingpasswordforuserixdba
这样就在/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'commanddefinition
definecommand{
command_namecheck_nrpe
command_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$
}


修改
contacts.cfg
添加联系人信息,内容如下:
definecontact{
contact_nametest1
aliassystemadministrator
service_notification_period24x7
host_notification_period24x7
service_notification_optionsw,u,c,r
host_notification_optionsd,u,r
service_notification_commandsnotify-service-by-email
host_notification_commandsnotify-host-by-email
emailtest1@nagios实施
}


修改
contactgroups.cfg
添加联系人组信息,内容如下:
definecontactgroup{
contactgroup_nameadmins
aliassystemadministratorgroup
memberstest1
}







添加被监控机监控机配置
首先/usr/local/nagios/libexec/check_nrpe-H$被监控主机ip
应该都能输出NRPE的版本:NRPEv2.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

成为第一个吐槽的人

Powered by IT 运维管理
返回顶部