nagios監(jiān)控多臺(tái)主機(jī)(nrpe)
目前創(chuàng)新互聯(lián)已為上1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、銅鼓網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
在被監(jiān)控機(jī)上安裝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
默認(rèn)為allowed_hosts=127.0.0.1
:wq
啟動(dòng)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
默認(rèn)為allowed_hosts=127.0.0.1
:wq
啟動(dòng)nrpe
# service nagios-nrpe-server start
查看NRPE 是否已經(jīng)啟動(dòng)
# netstat -nltp |grep nrpe
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 5163/nrpe
測(cè)試NRPE 是否則正常工作
# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
nrpe開機(jī)自啟動(dòng):
# vi /etc/rc.local
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
:wq
查看被監(jiān)控機(jī)上的check命令,監(jiān)控機(jī)監(jiān)控時(shí)要用
# 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
注:可以自行添加也可以修改后面的值(報(bào)警值)
如:
command[check_mapper]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/VolGroup00-LogVol00 (監(jiān)控硬盤卷)
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 (可以對(duì)硬盤各個(gè)分區(qū)都進(jìn)行監(jiān)控)
在監(jiān)控機(jī)器上安裝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
只運(yùn)行這一步就行了,因?yàn)橹恍枰猚heck_nrpe 插件
2、測(cè)試監(jiān)控機(jī)與被監(jiān)控機(jī)運(yùn)行的nrpedaemon 之間的通信.
# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.14
NRPE v2.8.1
看到已經(jīng)正確返回了NRPE 的版本信息,說明一切正常.
3、對(duì)主機(jī)192.168.1.14進(jìn)行監(jiān)控
在commands.cfg 中增加對(duì)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 中要使用這個(gè)名稱)
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ (這是定義實(shí)際運(yùn)行的插件程序)(-c 后面帶的$ARG1$參數(shù)是傳給nrpe
daemon 執(zhí)行的檢測(cè)命令)
# 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后面的命令是依據(jù)被監(jiān)控機(jī)的nrpe.cfg來寫,那上面有才能寫
# vi /usr/local/nagios/etc/nagios.cfg (任意處添加)
cfg_file=/usr/local/nagios/etc/objects/ming.cfg
:wq
重啟nagios服務(wù)
# service nagios restart
新聞名稱:nagios監(jiān)控多臺(tái)主機(jī)(nrpe)
網(wǎng)頁網(wǎng)址:http://www.rwnh.cn/article36/igidpg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、品牌網(wǎng)站制作、營銷型網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)公司、動(dòng)態(tài)網(wǎng)站、ChatGPT
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)