我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Nagios4.3.1监控Centos6.7

上一篇Nagios监控windows中已经写到Nagios的安装过程,这里不再重复。

成都创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站制作、做网站、外贸营销网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的关岭网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

基于NPRE检测linux

在linux主机上安装NRPE,并通过5666端口让服务端check_nrpe跟NRPE进行通讯

NRPE(Nagios Remote Plugin Executor)是用于在远端服务器上运行检测命令的守护进程,他用于让Nagios监控端基于安装的方式触发远端主机上的检测命令,并将检测结果输出至监控端,而其执行的开销远低于基于SSH的检测方式,而且检测过程并补需要远程主机上的系统账号等信息,其按期性也高于SSH的检测方式

安装前准备
调整系统时间
下载nagios-plugins-2.2.1.tar.gz
https://www.nagios.org/downloads/nagios-plugins/
下载nrpe-3.1.0.tar.gz

=============================================================
配置被监控端Nagios Client

1. 安装nrpe和nagios插件
[root@client ~]# yum install openssl openssl-devel xinetd gcc make

[root@client ~]# useradd nagios
[root@client ~]# tar xvf nagios-plugins-2.2.1.tar.gz
[root@client ~]# cd nagios-plugins-2.2.1
[root@client nagios-plugins-2.2.1]# ./configure && make && make install

[root@client ~]# tar xvf nrpe-2.13.tar.gz
[root@client ~]# cd nrpe-2.13
[root@client nrpe-2.13]# ./configure && make && make install
[root@client nrpe-2.13]# make install-daemon-config
[root@client nrpe-2.13]# make install-xinetd
[root@client nrpe-2.13]# vim /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1 10.200.1.23    //10.200.1.23 为nagios监控中心地址    #而且中间必须是空格
}
Nagios4.3.1监控Centos6.7[root@client nrpe-2.12]# vim /etc/services
nrpe 5666/tcp # NRPE //添加该行
[root@client nrpe-2.13]# service xinetd restart
[root@client nrpe-2.13]# chkconfig xinetd on          #添加开机自启动
[root@client nrpe-2.13]# chkconfig --list xinetd     #查看2345是否on

[root@client nrpe-2.13]# netstat -tunpl | grep 5666
tcp        0      0 :::5666                     :::*                        LISTEN      2818/xinetd   
Nagios4.3.1监控Centos6.7
2. 配置监控本地私有资源
[root@client nrpe-2.12]# 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
command[check_root]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/vg01-lv_root
command[check_home]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/vg01-lv_home
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
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 50% -c 40%
[root@client ~]# service xinetd restart

开放5666端口并重启防火墙
[root@localhost /]# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
Nagios4.3.1监控Centos6.7

[root@localhost /]# service iptables restart

[root@localhost ~]# netstat -tnlp     查看监听端口5666端口上已经开启了xinetd服务

Nagios4.3.1监控Centos6.7

========================================================
配置监控中心Nagios Server
1. 安装nrpe插件并测试
[root@master ~# tar xvf nrpe-2.13.tar.gz //仅需要check_nrpe插件
[root@master nrpe-2.13]# ./configure && make all && make install
[root@master ~]# /usr/local/nagios/libexec/check_nrpe -H 10.200.1.24
NRPE v2.13


定义主机和定义服务
[root@linyangjun local]# cd /etc/nagios/
编辑nagiios.cfg
增加cfg_file=/etc/nagios/objects/centos6.cfg  保存后退出
Nagios4.3.1监控Centos6.7切换到[root@linyangjun nagios]# cd objects/
[root@linyangjun objects]# vim cnetos6.cfg          #新增centos6.cfg 文件
填入内容:
# Define a host for the local machine

define host{
use linux-server
host_name Centos6                                   #监控端显示名称            
alias web-10.200.1.24
address 10.200.1.24                                 #被监控端IP  
}

# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
use local-service
host_name Centos6
service_description Root Partition
check_command check_nrpe!check_root
}

# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free
define service{
use local-service
host_name Centos6
service_description Swap Usage
check_command check_nrpe!check_swap
}

# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users.
define service{
use local-service
host_name Centos6
service_description Total Processes
check_command check_nrpe!check_total_procs
}

#保存后退出

/usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg   #可验证语法是否错误


测试通过之后重启nagios服务

#service nagios restart

Nagios4.3.1监控Centos6.7

在/usr/local/nagios/libexec 下,使用cher_nrpe -H 10.200.1.24 测试链接,显示版本号表示链接正常

Nagios4.3.1监控Centos6.7

重启完毕打开监控web界面,登录之后可以看到centos6已经在监控列表中

Nagios4.3.1监控Centos6.7


名称栏目:Nagios4.3.1监控Centos6.7
网页网址:http://shouzuofang.com/article/ipijpd.html

其他资讯