您好,登錄后才能下訂單哦!
nagios監控多臺主機(nrpe)
在被監控機上安裝nrpe
http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz
須先安裝nagios插件
方法1:
# useradd -s /sbin/nologin -M nagios
# apt-get install libssl-dev
# ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/
# tar -zxvf nagios-plugins-1.4.14.tar.gz
# cd nagios-plugins-1.4.14
# ./configure --prefix=/usr/local/nagios
# make && make install
# tar zxvf nrpe-2.12.tar.gz
# cd nrpe-2.12
# ./configure
# make all
# make install-plugin (安裝check_nrpe插件)
# make install-daemon (安裝deamon)
# make install-daemon-config (安裝配置文件)
編輯nrpe配置文件
# vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.10.8
默認為allowed_hosts=127.0.0.1
:wq
啟動nrpe
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
方法2(ubuntu):
# useradd -s /sbin/nologin -M nagios
# apt-get install nagios-nrpe-server nagios-plugins
編輯nrpe配置文件
# vi /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.10.8
默認為allowed_hosts=127.0.0.1
:wq
啟動nrpe
# service nagios-nrpe-server start
查看NRPE 是否已經啟動
# netstat -nltp |grep nrpe
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 5163/nrpe
測試NRPE 是否則正常工作
# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
nrpe開機自啟動:
# vi /etc/rc.local
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
:wq
查看被監控機上的check命令,監控機監控時要用
# vi /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_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1
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 20% -c 10%
:wq
注:可以自行添加也可以修改后面的值(報警值)
如:
command[check_mapper]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/VolGroup00-LogVol00 (監控硬盤卷)
command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda1 (有的是sda,要視情況而定)
command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda2 (可以對硬盤各個分區都進行監控)
在監控機器上安裝nrpe
1、安裝check_nrpe 插件
# apt-get install libssl-dev
# ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/
# tar -zxvf nrpe-2.8.1.tar.gz
# cd nrpe-2.8.1
# ./configure
# make all
# make install-plugin
只運行這一步就行了,因為只需要check_nrpe 插件
2、測試監控機與被監控機運行的nrpedaemon 之間的通信.
# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.14
NRPE v2.8.1
看到已經正確返回了NRPE 的版本信息,說明一切正常.
3、對主機192.168.1.14進行監控
在commands.cfg 中增加對check_nrpe 的定義
# vi /usr/local/nagios/etc/objects/commands.cfg
# 'check_nrpe ' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
:wq
意義如下 :
command_name check_nrpe (定義命令名稱為check_nrpe,在services.cfg 中要使用這個名稱)
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ (這是定義實際運行的插件程序)(-c 后面帶的$ARG1$參數是傳給nrpe
daemon 執行的檢測命令)
# cd /usr/local/nagios/etc/objects
# cp localhost.cfg ming.cfg
# vi ming.cfg
將host中的host_name改為ming,address改為192.168.1.14 (ming是隨意寫的)
將hostgroup_name改為ming,members也改為ming
define service {
use generic-service
host_name ming
service_description check_load
check_command check_nrpe!check_load
}
define service {
use generic-service
host_name ming
service_description check_users
check_command check_nrpe!check_users
}
define service {
use generic-service
host_name ming
service_description check_total
check_command check_nrpe!check_total_procs
}
define service {
use generic-service
host_name ming
service_description check_hda1
check_command check_nrpe!check_hda1
}
:wq
注:check_command后面的命令是依據被監控機的nrpe.cfg來寫,那上面有才能寫
# vi /usr/local/nagios/etc/nagios.cfg (任意處添加)
cfg_file=/usr/local/nagios/etc/objects/ming.cfg
:wq
重啟nagios服務
# service nagios restart
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。