本篇内容主要讲解“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,下面我只写操作命令,不多赘述了。
yum -y install httpd httpd-devel php openssl-devel gcc glibc glibc-common gd gd-devel
/usr/sbin/useradd -m nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
wget http://iweb.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.1/nagios-3.4.1.tar.gz
wget http://iweb.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
tar xzf nagios-3.4.1.tar.gz
cd nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
vi /usr/local/nagios/etc/objects/contacts.cfg 修改你的email地址
make install-webconf
为登录Nagios Web接口创建nagiosadmin帐号。记住下面你设置的密码,之后登录用到
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart
安装Nagios插件
tar xzf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
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监控远程主机
首先是远程被监控主机的操作
wget http://iweb.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz
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
tar xvfz nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
export LDFLAGS=-ldl
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
make
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec/
安装nrpe
tar xvfz nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
yum install xinetd
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是否正常工作
/usr/local/nagios/libexec/check_nrpe -H localhost
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
测试是否正常
/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主机”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!