189 8069 5689

centos6.2怎么用nagiosnrpe监控本地与远程Linux主机

本篇内容主要讲解“centos6.2怎么用nagios nrpe监控本地与远程Linux主机”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“centos6.2怎么用nagios nrpe监控本地与远程Linux主机”吧!

创新互联公司专业为企业提供花溪网站建设、花溪做网站、花溪网站设计、花溪网站制作等企业网站建设、网页设计与制作、花溪企业网站模板建站服务,10年花溪做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

假设我的监控主机ip是192.168.122.3,远程被监控主机是192.168.122.14.两个系统都是centos6.3系统。首先介绍监控本地主机。这部分很简单,可以参考Nagios 官方指导文档http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html,下面我只写操作命令,不多赘述了。

  1. yum -y install httpd httpd-devel php openssl-devel gcc glibc glibc-common gd gd-devel

  2. /usr/sbin/useradd -m nagios

  3. /usr/sbin/groupadd nagcmd

  4. /usr/sbin/usermod -a -G nagcmd nagios

  5. /usr/sbin/usermod -a -G nagcmd apache

  6. wget http://iweb.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.1/nagios-3.4.1.tar.gz

  7. wget http://iweb.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

  8. tar xzf nagios-3.4.1.tar.gz

  9. cd nagios

  10. ./configure --with-command-group=nagcmd

  11. make all

  12. make install

  13. make install-init

  14. make install-config

  15. make install-commandmode

  16. vi /usr/local/nagios/etc/objects/contacts.cfg 修改你的email地址

  17. make install-webconf

  18. 为登录Nagios Web接口创建nagiosadmin帐号。记住下面你设置的密码,之后登录用到
    htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

  19. service httpd restart

  20. 安装Nagios插件

    1. tar xzf nagios-plugins-1.4.16.tar.gz

    2. cd nagios-plugins-1.4.16

    3. ./configure --with-nagios-user=nagios --with-nagios-group=nagios

    4. make

    5. make install

21.  设置Nagios开机自启动

       chkconfig --add nagios

       chkconfig nagios on

22 测试配置文件是否有错误

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

23. 如果没有,就启动nagios  

       service nagios start

下面是介绍使用nrpe监控远程主机

首先是远程被监控主机的操作

  1. wget http://iweb.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz

  2. wget http://iweb.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

添加nagios 帐号

3. useradd nagios; passwd nagios

安装nagios-plugin

  1. tar xvfz nagios-plugins-1.4.16.tar.gz

  2. cd nagios-plugins-1.4.16

  3. export LDFLAGS=-ldl

  4. ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround

  5. make

  6. make install

  7. chown nagios.nagios /usr/local/nagios

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

安装nrpe

  1. tar xvfz nrpe-2.13.tar.gz

  2. cd nrpe-2.13

  3. ./configure

  4. make all

  5. make install-plugin

  6. make install-daemon

  7. make install-daemon-config

  8. yum install xinetd

  9. make install-xinetd

更改/etc/xinetd.d/nrpe文件,设置允许nagios服务器连接,如nagios服务器的ip为192.168.122.3

only_from       = 127.0.0.1 192.168.122.3

在/etc/services结尾增加

nrpe         5666/tcp         # NRPE

启动xinetd

service xinetd restart

验证nrpe是否监听

ss -an | grep 5666

测试nrpe是否正常工作

  1. /usr/local/nagios/libexec/check_nrpe -H localhost

  2. NRPE v2.13

更改 /usr/local/nagios/etc/nrpe.cfg
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

======================================================================

下面是nagios服务器的操作

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

tar xvfz nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin

测试是否正常

  1. /usr/local/nagios/libexec/check_nrpe -H 192.168.122.14

      NRPE v2.13

在文件/usr/local/nagios/etc/objects/commands.cfg后面增加:

# 'check_nrpe' command definition

define command{

command_name check_nrpe

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

}

创建/usr/local/nagios/etc/objects/remotehost.cfg
host定义示例:

define host{

use linux-server

host_name defcon

address 192.168.122.14

}

Service定义示例:

define service{

use generic-service

service_description Root Partition

check_command check_nrpe!check_disk

}

然后echo “cfg_file=/usr/local/nagios/etc/objects/remotehost.cfg” >> /usr/local/nagios/etc/nagios.cfg"

service nagisos reload就可以查看到远程主机和本地主机啦

centos6.2怎么用nagios nrpe监控本地与远程Linux主机

到此,相信大家对“centos6.2怎么用nagios nrpe监控本地与远程Linux主机”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


当前标题:centos6.2怎么用nagiosnrpe监控本地与远程Linux主机
标题路径:http://cdxtjz.com/article/jejihd.html

其他资讯