Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx

上传人:b****7 文档编号:22378655 上传时间:2023-02-03 格式:DOCX 页数:16 大小:19.71KB
下载 相关 举报
Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx_第1页
第1页 / 共16页
Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx_第2页
第2页 / 共16页
Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx_第3页
第3页 / 共16页
Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx_第4页
第4页 / 共16页
Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx

《Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx》由会员分享,可在线阅读,更多相关《Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx(16页珍藏版)》请在冰豆网上搜索。

Centos56下的Nagios详细配置之三nagios监控linux主机Word文件下载.docx

host>

[-n][-u][-p<

port>

][-t<

timeout>

][-c<

command>

]

使用方式:

check_nrpe-H主机名-pNRPE端口-cNRPE命令名

Options:

选项:

<

=TheaddressofthehostrunningtheNRPEdaemon

主机,运行着NRPE守护进程的远程被监测主机名,并且该主机名必须在host里定义过。

[port]=Theportonwhichthedaemonisrunning(default=5666)

端口,被监测的远程主机上运行NRPE的端口,默认是5666,如果是默认就不用指定。

[command]=Thenameofthecommandthattheremotedaemonshouldrun

命令,这些命令名必须是被监测主机上NRPE守护进程运行着的。

查看监控服务器是否能和远程Linux192.168.1.3正常通信。

能正常通信返回NRPE的版本号

[root@KCentOS5C~]#/usr/local/nagios/libexec/check_nrpe–H192.168.1.3

2.在command.cfg命令定义文件中添加NRPE命令。

[root@KCentOS5C~]#vi/usr/local/nagios/etc/objects/commands.cfg

添加如下NRPE功能命令

#NRPECommand

definecommand{

command_namecheck_nrpe

command_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$

}

这里要说明几点:

(1)这里定义的命令名就叫作nrpe。

(2)$USER1$/check_nrpe会通过引用resource.cfg获得/usr/local/nagios/libexec/check_nrpe这个绝对路径。

(3)-H$HOSTADDRESS$用来获得指定被监测主机的IP地址,$HOSTADDRESS$变量会通过定义主机名查找到host段中的IP地址。

(4)-c$ARG1$用来指定被监测主机上NRPE守护进程运行着的NRPE命令名。

3.在Nagios监控服务器上然后按照NRPE命令定义来添加NRPE远程监控服务:

#vi/usr/local/nagios/etc/objects/localhost.cfg

 

在localhost.cfg添加definehostdefineservice

definehost{

uselinux-server

host_namemylinux

aliasmylinux

address192.168.1.3;

远程Linux服务器的地址

}

defineservice{

usegeneric-service

host_namemylinux

service_descriptioncheck-swap//对下面操作的描述

check_commandcheck_nrpe!

check_swap//执行检测交换分区命令,监控swap

service_descriptioncheck-load

check_load//监控负载

service_descriptioncheck-disk

check_disk//监控硬盘

service_descriptioncheck-users

check_users//监控用户(使用)情况

service_descriptiontotal_procs

check_total_procs//监控进程

运行如下命令。

如果没有错误就可以重启Nagios服务

#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg

重启NagiosService使配置生效

#servicenagiosreload

监控主机和被监控主机如果启动Iptables防火墙的话,测试的时候可以停止iptables服务Serviceiptablesstop正真的使用中,需要开启Iptables,同时配置防火墙是Iptables的5666端口开放。

防火墙配置方法:

/sbin/iptables-AFORWARD-ieth0-ptcp--dport5666-jACCEPT

(三)在被监控主机上安装Nagios-plugins插件程序:

(下载地址

1.添加Nagios用户

#useraddnagios

安装软件包:

yum-yinstallgccopenssl-developenssl

2.下载插件

#mkdir~/downloads

3.准备好Nagios-plugins和NRPE源代码包

#ll

total2008

-rw-------1rootroot928Oct310:

33anaconda-ks.cfg

-rw-r--r--1rootroot22760Oct310:

33install.log

-rw-r--r--1rootroot2888Oct310:

33install.log.syslog

-rw-r--r--1rootroot1693979Sep3022:

51nagios-plugins-1.4.15.tar.gz

Nagios-plugins插件程序包

-rw-r--r--1rootroot305019Sep3022:

58nrpe-2.13.tar.gz

NRPE扩展插件功能包

4.解压Nagios-plugins压缩包

#tar-zxvfnagios-plugins-1.4.15.tar.gz

5.进入Nagios-plugins插件包目录

#cdnagios-plugins-1.4.15

6.预配置Nagios-plugins的安装路径

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

如提示出错请安装以下软件包:

yuminstallgcc

yuminstallglibcglibc-common

yuminstallgdgd-devel

yum-yinstallopensslopenssl-devel

预配置完成后会反馈信息并生成Makefile

config.status:

creatingpo/Makefile

--with-apt-get-command:

--with-ping6-command:

/bin/ping6-n-U-w%d-c%d%s

--with-ping-command:

/bin/ping-n-U-w%d-c%d%s

--with-ipv6:

yes

--with-mysql:

no

--with-openssl:

--with-gnutls:

--with-perl:

/usr/bin/perl

--enable-perl-modules:

--with-cgiurl:

/nagios/cgi-bin

--with-trusted-path:

/bin:

/sbin:

/usr/bin:

/usr/sbin

7.编译Nagios-plugins插件程序

#make

8.安装Nagios-plugins插件程序

#makeinstall

9.查看Nagios-plugins插件程序的安装

#ll/usr/local/nagios/

total8

drwxr-xr-x2rootroot4096Oct701:

02libexec

drwxr-xr-x3rootroot4096Oct701:

02share

10.递归更改Nagios主路径的属主

#chownnagios.nagios/usr/local/nagios/

#chown-Rnagios.nagios/usr/local/nagios/libexec

11.检查Nagios主路径的属性

#ll/usr/local/|grepnagios

drwxr-xr-x4nagiosnagios4096Oct701:

02nagios

[root@KCentOS5A~]#ll/usr/local/nagios/

drwxr-xr-x2nagiosnagios4096Oct701:

drwxr-xr-x3nagiosnagios4096Oct701:

(四)再在被监控主机上安装NRPE扩展插件程序:

(下载地址:

1.下载插件

原因缺少openssl-devel包,解决办法

安装:

yuminstallxinetd

2.解压NRPE的压缩包

#tar-zxvfnrpe-2.13.tar.gz

#cdnrpe-2.13

3.预配置NRPE安装程序

#./configure(--enable-ssl--with-ssl-lib=/lib/)

预配置完毕后会反馈提示信息以及建立Makefile

configure:

creating./config.status

creatingMakefile

creatingsrc/Makefile

creatingsubst

creatinginclude/config.h

***Configurationsummaryfornrpe2.908-13-2007***:

GeneralOptions:

-------------------------

NRPEport:

5666

NRPEuser:

nagios

NRPEgroup:

Nagiosuser:

Nagiosgroup:

Reviewtheoptionsaboveforaccuracy.Iftheylookokay,

type'

makeall'

tocompiletheNRPEdaemonandclient.

最后提示继续使用“makeall”命令来对NRPE守护程序以及客户端程序进行编译。

4.对NRPE程序进行编译

#makeall

编译成功后会反馈提示信息

***Compilefinished***

IftheNRPEdaemonandclientcompiledwithoutanyerrors,you

cancontinuewiththeinstallationorupgradeprocess.

ReadthePDFdocumentation(NRPE.pdf)forinformationonthenext

stepsyoushouldtaketocompletetheinstallationorupgrade.

在NRPE的包目录中有一份NRPE.pdf的手册,接下来就可以参考那份手册进行后续的操作了。

安装NRPE插件程序,守护程序以及模板守护程序配置文件。

InstalltheNRPEplugin(fortesting),daemon,andsampledaemonconfigfile.

5.安装NRPE插件程序

#makeinstall-plugin

6.安装NRPE守护程序

#makeinstall-daemon

7.安装NRPE守护程序配置文件

#makeinstall-daemon-config

8.检查NRPE程序的安装

total16

drwxrwxr-x2nagiosnagios4096Oct701:

16bin

16etc

15libexec

9.安装Xinetd相关配置文件

#makeinstall-xinetd

10.相关文件的修改

#vim/usr/local/nagios/etc/nrpe.cfg

allowed_host=192.168.1.2127.0.0.1//允许192.168.1.2对其监控(不同地址间加空格)

#vi/etc/services文件作如下修改:

nrpe5666/tcp#NRPE

#servicexinetdrestart

替代:

(如发现异常,或者更改了配置,用此方法重启下nrpe进程,也许可解决)

#psaux|grepnrpe

#killnagios的进程号

#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d

#tail/var/log/messages(查看nrpe日志,是否成功)

#killall-9nrpe

(五)在被监测主机上配置并运行NRPE

1.配置NRPE的主配置文件

usr/local/nagios/etc/nrpe.cfg配置文件默认就可以了。

2.找到NRPE运行的执行程序

#ll/usr/local/nagios/bin/nrpe

-rwxrwxr-x1nagiosnagios93420Oct701:

16/usr/local/nagios/bin/nrpe

3.了解NRPE的执行程序的使用方式

#/usr/local/nagios/bin/nrpe-h

nrpe[-n]-c<

config_file>

mode>

运行方法:

nrpe-cNRPE配置文件路径运行模式

可用选项

-n=DonotuseSSL

不使用SSL方式,一般都使用SSL。

=Nameofconfigfiletouse

指定NRPE配置文件路径,这个NRPE主配置文件就是nrpe.cfg。

=Oneofthefollowingtwooperatingmodes:

指定NRPE的运行方式,一共有2种可用的NRPE运行方式:

-i=Runasaserviceunderinetdorxinetd

以超级守护进程inetd或xinetd方式运行NRPE,要通过这种方式运行的话还要安装和配置xinetd,一般不用。

-d=Runasastandalonedaemon

以独立守护进程方式运行NRPE,一般常用这种运行方式。

4.运行NRPE守护进程

#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d

测试NEPE本地是否正常启动

#/usr/local/nagios/libexec/check_nrpe–Hlocalhost

如果正确的话,回返回NRPE的版本号

Errorcouldnotcompletesslhanshake

如果配置没有问题的话,输入如下命令。

查看配置是否配好

#netstat-at|grepnrpe

tcp00*:

nrpe*:

*LISTEN

5.查看系统日志检查NRPE运行情况:

#tail/var/log/messages

Oct701:

45:

10KCentOS5Anrpe[21659]:

Startingupdaemon

说明已经顺利启动了NRPE守护进程。

Listeningforconnectionsonport5666

说明已经启动了5666端口为NRPE的监听端口。

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

当前位置:首页 > PPT模板 > 可爱清新

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

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