nagios安装详解.docx

上传人:b****5 文档编号:11767779 上传时间:2023-04-01 格式:DOCX 页数:14 大小:20.17KB
下载 相关 举报
nagios安装详解.docx_第1页
第1页 / 共14页
nagios安装详解.docx_第2页
第2页 / 共14页
nagios安装详解.docx_第3页
第3页 / 共14页
nagios安装详解.docx_第4页
第4页 / 共14页
nagios安装详解.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

nagios安装详解.docx

《nagios安装详解.docx》由会员分享,可在线阅读,更多相关《nagios安装详解.docx(14页珍藏版)》请在冰豆网上搜索。

nagios安装详解.docx

nagios安装详解

Nagios参考文档

1.安装步骤:

1.主服务器端安装

1.1Apache安装

./configure--prefix=/www--enable-module=so--enable-module=expires--enable-module=headers--enable-module=rewrite>apache_install_result2>&1

make

makeinstall

1.2GDLib库安装

nagios生成和图形相关的cgi

1.3Php安装

./configure--prefix=/usr/local/php--with-apxs2=/www/bin/apxs--with-zlib=/usr--with-gd=/usr--with-png-dir=/usr--with-jpeg-dir=/usr

make

makeinstall

修改/monior/naigos/etc/nagios.cfg

添加

#AddTypetext/html.shtml

#AddOutputFilterINCLUDES.shtml

AddTypeapplication/x-httpd-php.php.php3.htm.phtml.php4

AddTypeapplication/x-httpd-php-source.phps

1.4Nagios安装

添加nagios用户和组

groupaddnagios

useradd-gnagios-d/home/nagios-mnagios

以上命令和操作系统有关,可能有所不同

建立安装目录

mkdir-p/monitor/nagios

修改安装目录的权限

chownnagios:

nagios/monitor/nagios

标识WebServer用户

grep"^User"/www/conf/httpd.conf

Userdaemon

表明用户名使daemon

./configure--prefix=/monitor/nagios\

--with-nagios-user=nagios\

--with-nagios-group=nagios\

--with-commang-group=nagios\

--with-httpd-conf=/www/conf

makeall

makeinstall

makeinstall-init

makeinstall-commandmode

makeinstall-config

makeinstall-webconf

设置页面访问权限

/www/bin/htpassword-c/monitor/nagios/etc/htpasswd.usersnagiosadmin

修改/monior/naigos/etc/nagios.cfg

log_rotation_method=h记录每小时平均数据

其他的配置均使用默认。

修改/monior/naigos/etc/cgi.cfg

允许使用cgi的用户与页面访问用户匹配

authorized_for_configuration_information=nagiosadmin

authorized_for_system_information=nagiosadmin

修改/www/conf/httpd.conf文件

ServerNameNagiosbak

文档最后添加:

include/www/conf/nagios.conf

/www/conf/nagios.conf定义认证模块

ScriptAlias/nagios/cgi-bin"/monitor/nagios/sbin"

#SSLRequireSSL

OptionsExecCGI

AllowOverrideNone

Orderallow,deny

Allowfromall

#Orderdeny,allow

#Denyfromall

#Allowfrom127.0.0.1

AuthName"NagiosAccess"

AuthTypeBasic

AuthUserFile/monitor/nagios/etc/htpasswd.users

Requirevalid-user

Alias/nagios"/monitor/nagios/share"

#SSLRequireSSL

OptionsNone

AllowOverrideNone

Orderallow,deny

Allowfromall

#Orderdeny,allow

#Denyfromall

#Allowfrom127.0.0.1

AuthName"NagiosAccess"

AuthTypeBasic

AuthUserFile/monitor/nagios/etc/htpasswd.users

Requirevalid-user

测试httpd.conf

/www/bin/apachectl-t

SyntaxOK #说明成功

访问地址http:

//192.168.1.179/nagios/

1.5RRDTool安装

没啥特别的。

Nagios主配置文件去掉注释(开放取性能数据)

host_perfdata_command=process-host-perfdata

service_perfdata_command=process-service-perfdata

修改/monitor/naigos/etc/object/command.cfg

definecommand{

command_nameprocess-host-perfdata

command_line/monitor/nagios/libexec/process_perfdata.pl

}

 

#'process-service-perfdata'commanddefinition

definecommand{

command_nameprocess-service-perfdata

command_line/monitor/nagios/libexec/process_perfdata.pl

}

1.6Qmail安装

按照原Qmail安装文档安装即可,无特殊设置。

2.被监控端安装(Linux)

2.1Nagios-Plugins安装

./configure--prefix=/usr/local/nagios;

Make;

Makeinstall;

2.2Nrpe安装

groupaddnagios;useradd-gnagios-d/home/nagios-mnagios

./configure--prefix=/usr/local/nagios;

makeall;

makeinstall-plugin;

makeinstall-daemon;

makeinstall-daemon-config;

makeinstall-xinetd

改变属主

chown–Rnagios:

nagios/usr/local/nagios

修改/etc/service

添加nrpe5666/tcp#NRPE

修改/etc/xinetd.d/nrpe

only_from=192.168.1.179允许谁来监控

nrpe服务隶属于xinetd服务安装完成后重启xinetd服务

验证

netstat-at|grepnrpe

tcp00*:

nrpe*:

*LISTEN

3.被监控端安装(windows)

下载nsclient丢到windows目录下

Cmd模式下安装

配置nsclient

编辑:

NSC.ini

去掉在[modules]段里的列出模块程序的注释,除了CheckWMI.dll和RemoteConfiguration.dll;

去掉在[Settings]段里的'allowed_hosts'选项注释,allowed_hosts=192.168.1.179/32确认一下在[NSClient]段里的'port'选项里已经去掉注释并设置成5666;

启动服务

2.监控服务器配置文件

目录/monitor/nagios/etc

2.1主配置文件nagios.cfg

为方便被监控机器管理,添加配置文件夹(nagios启动时会遍历以定义的目录下所有以.cfg结尾的文件)

cfg_dir=/monitor/nagios/etc/objects/servers

注释掉本地监控

#cfg_file=/monitor/nagios/etc/objects/localhost.cfg

其余均使用默认值。

2.2命令配置文件/object/command.cfg

例:

definecommand{

command_nameip_conns命令名

command_line$USER1$/ip_conns$ARG1$$ARG2$具体命令

}

由于定义在command的命令均为监控服务器主动发起的指令,会增加一定网络负载,我的配置中都不用,基本上可以只需要看看他自定义的命令怎么用就可以了。

2.3监控时间配置文件/objects/timeperiods.cfg

定义监控时间类型24*7工作时间等等

2.4联系人配置文件/objects/contacts.cfg

定义单个联系人

definecontact{

contact_namenagiosadmin定义用户

usegeneric-contact调用template.cfg中的generic-contact模板

aliasNagiosAdmin

emailhongyu.ma@

}

定义联系人组,可加多个联系人

definecontactgroup{

contactgroup_nameadmins

aliasNagiosAdministrators

membersnagiosadmin

}

2.5模板配置文件/objects/templates.cfg

defineservice{

namegeneric-service;模板名

active_checks_enabled1;允许主动监测服务就是使用command的命令

passive_checks_enabled1;允许被动监测服务就是使用nrpeparallelize_check1

obsess_over_service1

check_freshness0

notifications_enabled1允许通知

event_handler_enabled1允许记录主机事件

flap_detection_enabled1

failure_prediction_enabled1允许故障预告

retain_status_information1保存主机状态信息

retain_nonstatus_information1

is_volatile0

check_period24x7检查周期

max_check_attempts3最大重试次数

normal_check_interval10普通检查间隔

retry_check_interval2检查失败重试间隔

contact_groupsadmins联系组

notification_optionsw,u,c,r哪些需要报警除正常外均报警

notification_interval60报警间隔60分钟

notification_period24x7报警时间段

register0说明这只是个模板

}

目前所有服务均使用此模板

definehost{

namegeneric-host

notifications_enabled1

event_handler_enabled1

flap_detection_enabled1

failure_prediction_enabled1

retain_status_information1

retain_nonstatus_information1

notification_period24x7

register0

action_url/nagios/pnp/index.php?

host=$HOSTNAME$数据图像Url

process_perf_data1允许读取性能数据

}

所有主机均使用此模板

 

2.6Server下个主机配置

Nagios的配置有继承关系关键字use本地配置会覆盖继承配置

definehost{

namelinux-co

usegeneric-host

check_period24x7

check_interval5

retry_interval1

max_check_attempts10

check_commandcheck-host-alive

notification_period24x7

notification_interval30

notification_optionsd,r

contact_groupsadmins

register0

}

definehost{

uselinux-co使用上一级定义的主机模板

host_name5co2

alias5co2

address192.168.5.96

}

definehostgroup{

hostgroup_namelinux-Co

aliasCo

members5co2

}

2.7Service.cfg配置

我把大多数常用服务整合到了service.cfg配置下

defineservice{

usegeneric-service

hostgroup_namelinux-Sysmailmon,linux-Mysql,linux-Wap,linux-Nagios,linux-Co,linux-Www,linux-Internaltux,linux-JobMail,linux-Mytux,linux-Tjsearchweb,linux-Images,linux-Internalweb,linux-My,linux-Searchweb,linux-Tjwww,linux-Xytr之前定义的组名

//也可以对个别机器做host_name5www6

service_descriptionIPcons描述

check_commandcheck_nrpe!

ip_conns使用nrpe的被动监测方式

action_url/nagios/pnp/index.php?

host=$HOSTNAME$&srv=$SERVICEDESC$

process_perf_data1绘图需要这两个也可以定义在service模板里

}

2.8Windows服务配置

采用check_nt命令取值均为nsce软件自带。

defineservice{

usegeneric-service

hostgroup_namewindows-Newehireweb

service_descriptionCPULoad

check_commandcheck_nt!

CPULOAD!

-l5,80,90

}

2.9PNPrrdtool配置

Pnp的目录集合在nagios下

由于使用的是check_nrpe!

命令的模式pnp会默认先查询配置中是否对check_nrpe有配置定义,如无则再去核对/monitor/nagios/share/pnp/templates是否有相应的php模板。

新增配置/monitor/nagios/etc/pnp/check_commandscheck_nrpe.cfg

Pnp作图默认取下图中0的名字比对

#check_commandcheck_nwstat!

LOAD5!

80%!

90%

#________0__________||||

#________1____________________|||

#________2_________________________||

#________3____________________________|

#

CUSTOM_TEMPLATE=1取第2项核对模板

DATATYPE=GAUGE,GAUGE,COUNTER,COUNTER取多种类型数据

所有rrd的数据文件存在/monitor/nagios/share/perdata下。

2.10Nrpe配置/usr/local/nagios/etc/nrpe.cfg

首先保证nrpe的使用者是nagios

nrpe_user=nagios

nrpe_group=nagios

配置末尾处添加需要监测的命令

command[ip_conns]=/monitor/nagios/libexec/ip_conns200300

红色区域要与监控服务器里check_commandcheck_nrpe!

ip_conns红色部分对应

修改这个后不需要重启服务。

2.11邮件告警配置

配置文件command.cfg

主机邮件通知命令

definecommand{

command_namenotify-host-by-email

command_line/usr/bin/printf"%b""*****Nagios*****\n\nNotificationType:

$NOTIFICATIONTYPE$\nHost:

$HOSTNAME$\nState:

$HOSTSTATE$\nAddress:

$HOSTADDRESS$\nInfo:

$HOSTOUTPUT$\n\nDate/Time:

$LONGDATETIME$\n"|/bin/mail-s"**$NOTIFICATIONTYPE$HostAlert:

$HOSTNAME$is$HOSTSTATE$**"$CONTACTEMAIL$

}

definecommand{

command_namenotify-service-by-email

command_line/usr/bin/printf"%b""*****Nagios*****\n\nNotificationType:

$NOTIFICATIONTYPE$\n\nService:

$SERVICEDESC$\nHost:

$HOSTALIAS$\nAddress:

$HOSTADDRESS$\nState:

$SERVICESTATE$\n\nDate/Time:

$LONGDATETIME$\n\nAdditionalInfo:

\n\n$SERVICEOUTPUT$"|/bin/mail-s"**$NOTIFICATIONTYPE$ServiceAlert:

$HOSTALIAS$/$SERVICEDESC$is$SERVICESTATE$**"$CONTACTEMAIL$

再结合联系人配置

配置发送报警邮件时间间隔

notification_interval10表示10分钟发一次,可根据不同服务进行配置。

notification_optionsw,u,c,r表示那些状态需要报警

notification_period24x7表示报警时间段

目前在用的脚本

所有脚本均在nagioslibexec目录下

check_mem.pl监控内存和虚拟内存

/monitor/nagios/libexec/check_mem.pl-w110,50-c150,80

ip_conns监控tcp侦听数

/monitor/nagios/libexec/ip_conns200300

check_load监控服务器负载

/monitor/nagios/libexec/check_load-w15,10,5-c30,25,20

check_procs监控进程数(目前做了httpd和总进程,僵死进程)

/monitor/nagios/libexec/check_procs-ahttp-w20-c30

check_disk监控磁盘空间

/monitor/nagios/libexec/check_disk-w20%-c10%-p/var指定目录

Check_mailq监控邮件队列

/usr/bin/sudo/usr/local/nagios/libexec/check_mailq-w2000-c3000-Mqmail

check_tuxedo监控tuxedo是否排队

/usr/local/nagios/libexec/check_tuxedo15

由于nagios无执行tux的权限,在/etc/sudoer添加以下命令

nagiosALL=(ALL)NOPASSWD:

/usr/local/nagios/libexec/check_tuxedo

Memcache的三个监控

/usr/local/nagios/libexec/check_memcached_hits-w65-c50

/usr/local/nagios/libexec/check_memcached_requestcount-w50-c100

/usr/local/nagios/libexec/check_memcached_conns-w50-c100

 

补充

主服务器IP:

192.168.1.179

监控端安装目录:

/monitor/nagios

被监控端安装目录:

/usr/local/nagios

安装包位置:

192.168.1.179:

/opt/nagiosfile.20091025.tgz

/opt/rrdtool-1.2.6.tar.gz

/opt/php-5.3.0.tar.gz

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1