溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Nagios4.3.1監(jiān)控Centos6.7

發(fā)布時間:2020-08-01 07:47:30 來源:網(wǎng)絡(luò) 閱讀:642 作者:linyangjun123 欄目:移動開發(fā)

上一篇Nagios監(jiān)控windows中已經(jīng)寫到Nagios的安裝過程,這里不再重復(fù)。



基于NPRE檢測linux

在linux主機上安裝NRPE,并通過5666端口讓服務(wù)端check_nrpe跟NRPE進行通訊

NRPE(Nagios Remote Plugin Executor)是用于在遠端服務(wù)器上運行檢測命令的守護進程,他用于讓Nagios監(jiān)控端基于安裝的方式觸發(fā)遠端主機上的檢測命令,并將檢測結(jié)果輸出至監(jiān)控端,而其執(zhí)行的開銷遠低于基于SSH的檢測方式,而且檢測過程并補需要遠程主機上的系統(tǒng)賬號等信息,其按期性也高于SSH的檢測方式

安裝前準備
調(diào)整系統(tǒng)時間
下載nagios-plugins-2.2.1.tar.gz
https://www.nagios.org/downloads/nagios-plugins/
下載nrpe-3.1.0.tar.gz

=============================================================
配置被監(jiān)控端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監(jiān)控中心地址    #而且中間必須是空格
}
Nagios4.3.1監(jiān)控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監(jiān)控Centos6.7
2. 配置監(jiān)控本地私有資源
[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監(jiān)控Centos6.7

[root@localhost /]# service iptables restart

[root@localhost ~]# netstat -tnlp     查看監(jiān)聽端口5666端口上已經(jīng)開啟了xinetd服務(wù)

Nagios4.3.1監(jiān)控Centos6.7


========================================================
配置監(jiān)控中心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


定義主機和定義服務(wù)
[root@linyangjun local]# cd /etc/nagios/
編輯nagiios.cfg
增加cfg_file=/etc/nagios/objects/centos6.cfg  保存后退出
Nagios4.3.1監(jiān)控Centos6.7切換到[root@linyangjun nagios]# cd objects/
[root@linyangjun objects]# vim cnetos6.cfg          #新增centos6.cfg 文件
填入內(nèi)容:
# Define a host for the local machine

define host{
use linux-server
host_name Centos6                                   #監(jiān)控端顯示名稱            
alias web-10.200.1.24
address 10.200.1.24                                 #被監(jiān)控端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服務(wù)

#service nagios restart

Nagios4.3.1監(jiān)控Centos6.7


在/usr/local/nagios/libexec 下,使用cher_nrpe -H 10.200.1.24 測試鏈接,顯示版本號表示鏈接正常

Nagios4.3.1監(jiān)控Centos6.7



重啟完畢打開監(jiān)控web界面,登錄之后可以看到centos6已經(jīng)在監(jiān)控列表中

Nagios4.3.1監(jiān)控Centos6.7




向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI