Nagios4.3.1监控Centos6.7

发布时间:2020-08-01 07:47:30 作者:linyangjun123
来源:网络 阅读:648

上一篇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




推荐阅读:
  1. centos6.7安装单节点postgresql
  2. 基于CentOS6.7编译安装LAMP

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux 服务器 windows

上一篇:springcloud 整合 springboot-admin 监控中心 代码片段

下一篇:Android学习笔记:ListView及BaseAdapter使用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》