成都创新互联网站制作重庆分公司

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

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章题目:Nagios4.3.1监控Centos6.7-创新互联
网址分享:http://cxhlcq.com/article/dhehoe.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部