您好,登錄后才能下訂單哦!
NRPE擴展插件包含兩個部分:
a)check_nrpe插件,在監測主機上運行
b)NRPE守護進程,運行在遠程機器上,用于監測遠程Linux/Unix機器
當Nagios需要監測遠程主機的服務資源時:
a)Nagios將執行check_nrpe插件并告訴它需要監測的服務
b)check_nrpe插件通過受保護的加密方式(可選)來連接遠程主機上的NRPE守護進程
c)NRPE守護進程通過運行相應的Nagios插件來監測本機上的服務或資源
d)來自NRPE守護進程的服務監測結果被反饋給監測主機上的check_nrpe插件,這一監測結果表示Nagios進程的監測結果。
注意:NRPE守護進程要求遠程Linux/Unix主機必須安裝Nagios插件,否則,守護進程發揮不了任何作用。
為了完成以下安裝操作,你必須要:
a)以root身份來訪問遠程Linux/Unix主機
b)以nagios用戶賬戶來訪問監測主機
/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>
#我修改的內容如下(逗號之間沒有空格)
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 #顯示下面的結果是正確的
tcp 0 0 *:nrpe *:* LISTEN
如果不正確,請確定您已經完成了一下內容:
– 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 #出現下面的結果不要擔心,試試下一條命令
CHECK_NRPE: Error - Could not complete SSLhandshake. #我沒有解決這個問題
/usr/local/nagios/libexec/check_nrpe -H127.0.0.1 #下面的結果是正確的,安裝成功
NRPE v2.15
/usr/local/nagios/libexec/check_nrpe -H10.10.54.112 #下面的結果是正確的,安裝成功
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
#被我注釋掉的這個命令沒有用了,因為現在的磁盤不是/dev/hda1的了
#command[check_hda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/hda1
#下面這個命令是我添加的,經測試,有效
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
#測試我剛才自定義的命令
/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
#添加以下內容
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
#監測CPU
define service{
use generic-service
host_name remotehost
service_description CPU Load
check_command check_nrpe!check_load
}
#監測在線用戶
define service{
use generic-service
host_name remotehost
service_description Current Users
check_command check_nrpe!check_users
}
#檢測/dev/sda1的空間
define service{
use generic-service
host_name remotehost
service_description /dev/sda1 Free Space
check_command check_nrpe!check_sda1
}
#監測進程數
define service{
use generic-service
host_name remotehost
service_description Total Processes
check_command check_nrpe!check_total_procs
}
#監測僵尸進程
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查看
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。