在上一篇文章中 纳吉奥斯 3.0快速入门指南 ,我解释了Red Hat Server上Nagios 3.0的概述,安装和配置。在接下来的三章中,我’ll解释如何监视远程Linux主机以及在远程主机上运行的各种服务。另外,请参阅我们所有的 纳吉奥斯文章.
一,概述
二。在远程主机上安装Nagios插件和NRPE的6个步骤。
- 下载Nagios插件和NRPE附加组件
- 创建nagios帐户
- 安装Nagios插件
- 安装NRPE
- 设置NRPE以作为守护程序运行
- 修改/usr/local/nagios/etc/nrpe.cfg
三, 纳吉奥斯监视服务器上的4个配置步骤,用于监视远程主机:
- 下载NRPE附加组件
- 安装check_nrpe
- 为远程主机创建主机和服务定义
- 重新启动nagios服务
一,概述:
.
当Nagios(安装在nagios服务器上)监视远程Linux主机上的服务(例如磁盘空间使用情况)时,将在非常高的级别上执行以下三个步骤。
- 纳吉奥斯将在nagios-server上执行check_nrpe命令,并请求它使用check_disk命令监视远程主机上的磁盘使用情况。
- 纳吉奥斯服务器上的check_nrpe将联系远程主机上的NRPE守护程序,并请求它在远程主机上执行check_disk。
- NRPE守护程序将把check_disk命令的结果返回给nagios-server上的check_nrpe。
以下流程总结了以上解释:
纳吉奥斯服务器(check_nrpe)—–>远程主机(NRPE守护进程)—–> check_disk
纳吉奥斯服务器(check_nrpe)<—–远程主机(NRPE守护进程)<—–check_disk(返回磁盘空间使用情况)
二。在远程主机上安装Nagios插件和NRPE的7个步骤
.
1.下载Nagios插件和NRPE插件
从下载以下文件 纳吉奥斯.org和move 至 /home/downloads:
- 纳吉奥斯-plugins-1.4.11.tar.gz
- nrpe-2.12.tar.gz
2.创建nagios帐户
[remotehost]# 用户添加 纳吉奥斯 [remotehost]# passwd 纳吉奥斯
3.安装nagios-plugin
[remotehost]# cd /home/downloads [remotehost]# tar xvfz 纳吉奥斯-plugins-1.4.11.tar.gz [remotehost]# cd 纳吉奥斯-plugins-1.4.11 [remotehost]# export LDFLAGS=-ldl [remotehost]# 。/配置 --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround [remotehost]# 使 [remotehost]# 进行安装 [remotehost]# chown 纳吉奥斯.nagios /usr/local/nagios [remotehost]# chown -R 纳吉奥斯.nagios /usr/local/nagios/libexec/
注意: On Red Hat, For me the 。/配置 命令was hanging with the the message: “正在检查redhat spopen问题…”。加--./configure命令的enable-redhat-pthread-workaround作为上述问题的解决方法。
4.安装NRPE
[remotehost]# cd /home/downloads [remotehost]# tar xvfz nrpe-2.12.tar.gz [remotehost]# cd nrpe-2.12 [remotehost]# 。/配置 [remotehost]# 全部制作 [remotehost]# 进行安装-plugin [remotehost]# 进行安装-daemon [remotehost]# 进行安装-daemon-config [remotehost]# 进行安装-xinetd
5.设置NRPE作为守护程序运行(即作为xinetd的一部分):
- 修改/etc/xinetd.d/nrpe,将Nagios监视服务器的ip地址添加到only_from指令。请注意,127.0.0.1和nagios监视服务器ip-address之间有一个空格(在此示例中,nagios监视服务器ip-address为:192.168.1.2)
上ly_from = 127.0.0.1 192.168.1.2
- 修改/ etc / services并在文件末尾添加以下内容。
nrpe 5666/tcp # NRPE
- 启动服务
[remotehost]#service xinetd restart
- 验证NRPE是否正在监听
[remotehost]# netstat -at | grep nrpe tcp 0 0 *:nrpe *:* LISTEN
- Verify 至 使 sure the NRPE is functioning properly
[remotehost]# /usr/local/nagios/libexec/check_nrpe -H 本地主机 NRPE v2.12
6.修改/usr/local/nagios/etc/nrpe.cfg
远程主机上的nrpe.cfg文件包含检查远程主机上的服务所需的命令。默认情况下,nrpe.cfg附带一些标准检查命令作为示例。下面以check_users和check_load为例。
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10 command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
在所有检查命令中,“-w” stands for “Warning” and “-c” stands for “Critical”。例如在下面的check_disk命令中,如果可用磁盘空间减少了20%,nagios将发送警告消息。如果达到10%或更少,nagios将发送关键消息。更改值“-c” and “-w”以下参数取决于您的环境。
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
注意: 您可以在远程主机上的命令行上执行nrpe.cfg中显示的任何命令,并亲自查看结果。例如当我在命令行上执行check_disk命令时,它显示以下内容:
[remotehost]#/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1 DISK 危急 - free space: / 6420 MB (10% inode=98%);| /=55032MB;51792;58266;0;64741
在上面的示例中,由于/ dev / hda1上的可用磁盘空间仅为10%,因此它将显示CRITICAL消息,该消息将返回给nagios服务器。
三, 纳吉奥斯监视服务器上的4个配置步骤,用于监视远程主机:
.
1.下载NRPE附加组件
从下载nrpe-2.12.tar.gz 纳吉奥斯.org和move 至 /home/downloads:
2.在nagios监视服务器上安装check_nrpe
[nagios-server]# tar xvfz nrpe-2.12.tar.gz [nagios-server]# cd nrpe-2.1.2 [nagios-server]# 。/配置 [nagios-server]# 全部制作 [nagios-server]# 进行安装-plugin ./configure will give a configuration summary as shown below: *** Configuration summary for nrpe 2.12 05-31-2008 ***: General Options: ————————- NRPE port: 5666 NRPE user: 纳吉奥斯 NRPE group: 纳吉奥斯 Nagios user: 纳吉奥斯 Nagios group: 纳吉奥斯
注意: 我拿到“检查SSL标头…配置:错误:找不到ssl标头”执行./configure时出现错误消息。如下所示安装openssl-devel,然后再次运行./configure来解决此问题。
[nagios-server]# rpm -ivh openssl-devel-0.9.7a-43.16.i386.rpm krb5-devel-1.3.4-47.i386.rpm zlib-devel-1.2.1.2-1.2.i386.rpm e2fsprogs-devel-1.35-12.5. el4.i386.rpm warning: openssl-devel-0.9.7a-43.16.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e Preparing… ########################################### [100%] 1:e2fsprogs-devel ########################################### [ 25%] 2:krb5-devel ########################################### [ 50%] 3:zlib-devel ########################################### [ 75%] 4:openssl-devel ########################################### [100%]
验证nagios监视服务器是否可以与远程主机对话。
[nagios-server]#/usr/local/nagios/libexec/check_nrpe -H 192.168.1.3 NRPE v2.12
注意: 如上第二节所述,在安装了NRPE和nagios插件的remotehost的ip地址中为192.168.1.3。
3.为remotehost创建主机和服务定义
创建一个新的配置文件 / usr / local / 纳吉奥斯 / etc / objects/remotehost.cfg 为该特定的远程主机定义主机和服务定义。最好使用localhost.cfg并将其复制为remotehost.cfg并根据需要开始对其进行修改。
主机定义样本:
定义主机{ use linux-server host_name remotehost alias Remote Host address 192.168.1.3 contact_groups admins }
服务定义样本:
定义服务{ use generic-service service_description Root Partition contact_groups admins check_command check_nrpe!check_disk }
注意:在以上所有示例中,将remotehost替换为您的remotehost的相应主机名。
4.重新启动nagios服务
如下所示重新启动nagios并登录到nagios网站(http:// 纳吉奥斯-server / 纳吉奥斯 /)以验证已添加到nagios中进行监视的remotehost linux服务器的状态。
[nagios-server]# service 纳吉奥斯 reload
最佳纳吉斯书
纳吉奥斯 Core 3电子书 –我已经使用Nagios已有好几年了,知道Nagios正在监视我的所有系统,并且可以在任何潜在问题发生之前向我发出警告,我可以在晚上安然入睡。我强烈建议您阅读Nagios Core 3电子书,以获得对Nagios的详细了解。由于Nagios是免费软件,因此花几美元买书可能是您可以做出的最佳投资。
真棒Nagios文章
以下是一些很棒的 纳吉奥斯文章 对您可能会有所帮助。
如果您喜欢这篇文章,您可能还会喜欢..
![]() |
![]() |
![]() |
![]() |
您也可以修改commands.cfg以添加该文件中默认未包含的check_nrpe。
我在论坛中找到了下一行:
# ‘check_nrpe’ 命令definition
定义命令{
command_name check_nrpe
command_line $ USER1 $ / check_nrpe -H $ HOSTADDRESS $ -t 30 -c $ ARG1 $
}
感谢您的指导!!