资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Nagios_监测系统信息

1. 简介

1.1设计概览

Nagios_监测系统信息

目前累计服务客户成百上千,积累了丰富的产品开发及服务经验。以网站设计水平和技术实力,树立企业形象,为客户提供做网站、成都网站设计、网站策划、网页设计、网络营销、VI设计、网站改版、漏洞修补等服务。创新互联始终以务实、诚信为根本,不断创新和提高建站品质,通过对领先技术的掌握、对创意设计的研究、对客户形象的视觉传递、对应用系统的结合,为客户提供更好的一站式互联网解决方案,携手广大客户,共同发展进步。

NRPE扩展插件包含两个部分:

a)check_nrpe插件,在监测主机上运行

b)NRPE守护进程,运行在远程机器上,用于监测远程Linux/Unix机器

当Nagios需要监测远程主机的服务资源时:

a)Nagios将执行check_nrpe插件并告诉它需要监测的服务

b)check_nrpe插件通过受保护的加密方式(可选)来连接远程主机上的NRPE守护进程

c)NRPE守护进程通过运行相应的Nagios插件来监测本机上的服务或资源

d)来自NRPE守护进程的服务监测结果被反馈给监测主机上的check_nrpe插件,这一监测结果表示Nagios进程的监测结果。

注意:NRPE守护进程要求远程Linux/Unix主机必须安装Nagios插件,否则,守护进程发挥不了任何作用。

2. 安装过程

2.1前提条件

为了完成以下安装操作,你必须要:

a)以root身份来访问远程Linux/Unix主机

b)以nagios用户账户来访问监测主机

2.2在远程主机上的操作:

2.2.1 创建用户

/usr/sbin/useradd nagios –s /sbin/nologin

passwd nagios

2.2.2 下载安装Nagio插件

wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz

2.2.3 解压

tar xvf nagios-plugins-2.0.tar.gz

cd nagios-plugins-2.0

2.2.4 编译安装

./configure && make && makeinstall

2.2.5 修改目录权限

chown nagios.nagios /usr/local/nagios

chown -R nagios.nagios/usr/local/nagios/libexec

2.2.6 安装xinetd

yum install xinetd

2.2.7 安装NRPE服务

#解压

tar xvf nrpe-2.15.tar.gz

cd nrpe-2.15

2.2.8 编译安装

./configure

make all

2.2.9 安装NRPE插件(测试用),服务,以及一些简单的配置文件样例

make install-plugin

make install-daemon

make install-daemon-config

2.2.10 安装NRPE进程为xinetd的一个服务

make install-xinetd

2.2.11 编辑/etc/xinetd.d/nrpe文件,添加监测服务器的IP地址和本机IP地址

vim /etc/xinetd.d/nrpe

only_from = 127.0.0.1

#我修改的内容如下(逗号之间没有空格)

only_from =127.0.0.1,10.10.54.111,10.10.54.112

2.2.12 在/etc/services文件中添加NRPE进程的端口号

vim /etc/services

nrpe         5666/tcp         # NRPE

2.2.13 重启xinetd服务

service xinetd restart

2.2.14 测试本地NRPE进程

netstat -at | grep nrpe             #显示下面的结果是正确的

tcp  0     0 *:nrpe  *:*           LISTEN

如果不正确,请确定您已经完成了一下内容:

– You added the nrpe entry to your /etc/services file

– The only_from directive in the /etc/xinetd.d/nrpe file contains anentry for "127.0.0.1"

– xinetd is installed and started

– Check the system log files for references about xinetd or nrpe andfix any problems that are reported

2.2.15 测试进程

/usr/local/nagios/libexec/check_nrpe -Hlocalhost                   #出现下面的结果不要担心,试试下一条命令

CHECK_NRPE: Error - Could not complete SSLhandshake.     #我没有解决这个问题

/usr/local/nagios/libexec/check_nrpe -H127.0.0.1                  #下面的结果是正确的,安装成功

NRPE v2.15

/usr/local/nagios/libexec/check_nrpe -H10.10.54.112           #下面的结果是正确的,安装成功

NRPE v2.15

2.2.16 修改防火墙规则(我的防火墙一直是关着的,这不是个好习惯)

iptables -I RH-Firewall-1-INPUT -p tcp -mtcp –dport 5666 -j ACCEPT

service iptables save

2.2.17 修改/usr/local/nagios/etc/nrpe.cfg,可以自定义命令

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

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

        #被我注释掉的这个命令没有用了,因为现在的磁盘不是/dev/hda1的了

#command[check_hda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/hda1

        #下面这个命令是我添加的,经测试,有效

command[check_sda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/sda1

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs-w 5 -c 10 -s Z

command[check_total_procs]=/usr/local/nagios/libexec/check_procs-w 150 -c 200

        #测试我刚才自定义的命令

/usr/local/nagios/libexec/check_disk -w 20%-c 10% -p /dev/sda1

DISK OK - free space: /boot 158 MB (86%inode=99%);| /boot=25MB;154;173;0;193

2.2.18 重启nrpe服务

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

2.3 在监测主机上操作

2.3.1 在已配置Nagios的主机上,需要进行以下操作:

– Install the check_nrpe plugin

– Create a Nagios command definition for using the check_nrpe plugin

– Create Nagios host and service definitions for monitoring theremote host

2.3.2 下载NRPE源码包

wget http://ncu.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

2.3.3 解压

tar xvf nrpe-2.15.tar.gz

cd nrpe-2.15

2.3.4编译安装

./configure

make all

2.3.5 安装插件

make install-plugin

2.3.6 测试NRPE进程,IP地址为远程主机的IP

/usr/local/nagios/libexec/check_nrpe -H 10.10.54.112

NRPE v2.15

2.3.7 修改commands.cfg

vim /usr/local/nagios/etc/objects/commands.cfg

        #添加以下内容

define command{

command_name              check_nrpe

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

}

2.3.8 创建host和service定义

        #定义host

define host{

name                                   linux-box                   ; Name of this template

use                                       generic-host           ; Inherit default values

check_                                  period 24x7

check_                                  interval 5

retry_                                   interval 1

max_check_                       attempts 10

check_command              check-host-alive

notification_period         24x7

notification_interval      30

notification_options       d,r

contact_groups                admins

register                              0               ; DONT REGISTER THIS - ITS ATEMPLATE

}

        #定义service

                  #监测CPU

define service{

      use                            generic-service

      host_name                      remotehost

      service_description                     CPU Load

      check_command                 check_nrpe!check_load

      }

                  #监测在线用户

define service{

      use                            generic-service

      host_name                      remotehost

      service_description                     Current Users

      check_command                  check_nrpe!check_users

      }

                  #检测/dev/sda1的空间

define service{

      use                            generic-service

      host_name                      remotehost

      service_description                     /dev/sda1 Free Space

      check_command                  check_nrpe!check_sda1

      }

                  #监测进程数

define service{

      use                            generic-service

      host_name                      remotehost

      service_description                     Total Processes

      check_command                  check_nrpe!check_total_procs

      }

                  #监测僵尸进程

define service{

      use                            generic-service

      host_name                      remotehost

      service_description                     ZombieProcesses

      check_command                  check_nrpe!check_zombie_procs

      }

2.3.9 检测配置文件

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

Things look okay - No serious problems weredetected during the pre-flight check

2.3.10 重启服务

service nagios restart

3. 在监测主机查看

在浏览器输入http://10.10.54.111/nagios查看


网站题目:Nagios_监测系统信息
分享路径:http://cdkjz.cn/article/psssoi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220