上一篇Nagios監(jiān)控windows中已經(jīng)寫到Nagios的安裝過程,這里不再重復。
成都創(chuàng)新互聯(lián)專注于南岔企業(yè)網(wǎng)站建設,成都響應式網(wǎng)站建設公司,商城網(wǎng)站建設。南岔網(wǎng)站建設公司,為南岔等地區(qū)提供建站服務。全流程按需定制開發(fā),專業(yè)設計,全程項目跟蹤,成都創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務基于NPRE檢測linux
在linux主機上安裝NRPE,并通過5666端口讓服務端check_nrpe跟NRPE進行通訊
NRPE(Nagios Remote Plugin Executor)是用于在遠端服務器上運行檢測命令的守護進程,他用于讓Nagios監(jiān)控端基于安裝的方式觸發(fā)遠端主機上的檢測命令,并將檢測結果輸出至監(jiān)控端,而其執(zhí)行的開銷遠低于基于SSH的檢測方式,而且檢測過程并補需要遠程主機上的系統(tǒng)賬號等信息,其按期性也高于SSH的檢測方式
安裝前準備
調整系統(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)控中心地址 #而且中間必須是空格
}[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
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
[root@localhost /]# service iptables restart
[root@localhost ~]# netstat -tnlp 查看監(jiān)聽端口5666端口上已經(jīng)開啟了xinetd服務
========================================================
配置監(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
定義主機和定義服務
[root@linyangjun local]# cd /etc/nagios/
編輯nagiios.cfg
增加cfg_file=/etc/nagios/objects/centos6.cfg 保存后退出切換到[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 #監(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服務
#service nagios restart
在/usr/local/nagios/libexec 下,使用cher_nrpe -H 10.200.1.24 測試鏈接,顯示版本號表示鏈接正常
重啟完畢打開監(jiān)控web界面,登錄之后可以看到centos6已經(jīng)在監(jiān)控列表中
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網(wǎng)站題目:Nagios4.3.1監(jiān)控Centos6.7-創(chuàng)新互聯(lián)
文章出自:http://www.chinadenli.net/article4/dhehoe.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設、面包屑導航、網(wǎng)站改版、小程序開發(fā)、網(wǎng)站收錄、服務器托管
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內容