您好,登錄后才能下訂單哦!
NRPE擴(kuò)展插件包含兩個(gè)部分:
a)check_nrpe插件,在監(jiān)測(cè)主機(jī)上運(yùn)行
b)NRPE守護(hù)進(jìn)程,運(yùn)行在遠(yuǎn)程機(jī)器上,用于監(jiān)測(cè)遠(yuǎn)程Linux/Unix機(jī)器
當(dāng)Nagios需要監(jiān)測(cè)遠(yuǎn)程主機(jī)的服務(wù)資源時(shí):
a)Nagios將執(zhí)行check_nrpe插件并告訴它需要監(jiān)測(cè)的服務(wù)
b)check_nrpe插件通過(guò)受保護(hù)的加密方式(可選)來(lái)連接遠(yuǎn)程主機(jī)上的NRPE守護(hù)進(jìn)程
c)NRPE守護(hù)進(jìn)程通過(guò)運(yùn)行相應(yīng)的Nagios插件來(lái)監(jiān)測(cè)本機(jī)上的服務(wù)或資源
d)來(lái)自NRPE守護(hù)進(jìn)程的服務(wù)監(jiān)測(cè)結(jié)果被反饋給監(jiān)測(cè)主機(jī)上的check_nrpe插件,這一監(jiān)測(cè)結(jié)果表示Nagios進(jìn)程的監(jiān)測(cè)結(jié)果。
注意:NRPE守護(hù)進(jìn)程要求遠(yuǎn)程Linux/Unix主機(jī)必須安裝Nagios插件,否則,守護(hù)進(jìn)程發(fā)揮不了任何作用。
為了完成以下安裝操作,你必須要:
a)以root身份來(lái)訪(fǎng)問(wèn)遠(yuǎn)程Linux/Unix主機(jī)
b)以nagios用戶(hù)賬戶(hù)來(lái)訪(fǎng)問(wèn)監(jiān)測(cè)主機(jī)
/usr/sbin/useradd nagios –s /sbin/nologin
passwd nagios
wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
tar xvf nagios-plugins-2.0.tar.gz
cd nagios-plugins-2.0
./configure && make && makeinstall
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios/usr/local/nagios/libexec
yum install xinetd
#解壓
tar xvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
vim /etc/xinetd.d/nrpe
only_from = 127.0.0.1<nagios_ip_address>
#我修改的內(nèi)容如下(逗號(hào)之間沒(méi)有空格)
only_from =127.0.0.1,10.10.54.111,10.10.54.112
vim /etc/services
nrpe 5666/tcp # NRPE
service xinetd restart
netstat -at | grep nrpe #顯示下面的結(jié)果是正確的
tcp 0 0 *:nrpe *:* LISTEN
如果不正確,請(qǐng)確定您已經(jīng)完成了一下內(nèi)容:
– You added the nrpe entry to your /etc/services file
– The only_from directive in the /etc/xinetd.d/nrpe file contains anentry for "127.0.0.1"
– xinetd is installed and started
– Check the system log files for references about xinetd or nrpe andfix any problems that are reported
/usr/local/nagios/libexec/check_nrpe -Hlocalhost #出現(xiàn)下面的結(jié)果不要擔(dān)心,試試下一條命令
CHECK_NRPE: Error - Could not complete SSLhandshake. #我沒(méi)有解決這個(gè)問(wèn)題
/usr/local/nagios/libexec/check_nrpe -H127.0.0.1 #下面的結(jié)果是正確的,安裝成功
NRPE v2.15
/usr/local/nagios/libexec/check_nrpe -H10.10.54.112 #下面的結(jié)果是正確的,安裝成功
NRPE v2.15
iptables -I RH-Firewall-1-INPUT -p tcp -mtcp –dport 5666 -j ACCEPT
service iptables save
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
#被我注釋掉的這個(gè)命令沒(méi)有用了,因?yàn)楝F(xiàn)在的磁盤(pán)不是/dev/hda1的了
#command[check_hda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/hda1
#下面這個(gè)命令是我添加的,經(jīng)測(cè)試,有效
command[check_sda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/sda1
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
#測(cè)試我剛才自定義的命令
/usr/local/nagios/libexec/check_disk -w 20%-c 10% -p /dev/sda1
DISK OK - free space: /boot 158 MB (86%inode=99%);| /boot=25MB;154;173;0;193
/usr/local/nagios/bin/nrpe -c/usr/local/nagios/etc/nrpe.cfg –d
– Install the check_nrpe plugin
– Create a Nagios command definition for using the check_nrpe plugin
– Create Nagios host and service definitions for monitoring theremote host
wget http://ncu.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar xvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
/usr/local/nagios/libexec/check_nrpe -H 10.10.54.112
NRPE v2.15
vim /usr/local/nagios/etc/objects/commands.cfg
#添加以下內(nèi)容
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#定義host
define host{
name linux-box ; Name of this template
use generic-host ; Inherit default values
check_ period 24x7
check_ interval 5
retry_ interval 1
max_check_ attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS ATEMPLATE
}
#定義service
#監(jiān)測(cè)CPU
define service{
use generic-service
host_name remotehost
service_description CPU Load
check_command check_nrpe!check_load
}
#監(jiān)測(cè)在線(xiàn)用戶(hù)
define service{
use generic-service
host_name remotehost
service_description Current Users
check_command check_nrpe!check_users
}
#檢測(cè)/dev/sda1的空間
define service{
use generic-service
host_name remotehost
service_description /dev/sda1 Free Space
check_command check_nrpe!check_sda1
}
#監(jiān)測(cè)進(jìn)程數(shù)
define service{
use generic-service
host_name remotehost
service_description Total Processes
check_command check_nrpe!check_total_procs
}
#監(jiān)測(cè)僵尸進(jìn)程
define service{
use generic-service
host_name remotehost
service_description ZombieProcesses
check_command check_nrpe!check_zombie_procs
}
/usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
Things look okay - No serious problems weredetected during the pre-flight check
service nagios restart
在瀏覽器輸入http://10.10.54.111/nagios查看
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。