網(wǎng)上找了一些資料,結(jié)合自己搭建總結(jié)的文章,希望對(duì)需要的朋友有幫助!
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、外貿(mào)營銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的融水網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
實(shí)驗(yàn)環(huán)境配置
1、 環(huán)境搭建
Server: nagios nagios-plugins nrpe
工作站:nagios-plugins nrpe
檢查一下包的安裝情況
# rpm -q httpd gcc glibc glibc-common gd gd-devel
#yum -y httpd gcc glibc glibc-common gd gd-devel
-----------------------------------------------------
在server 端配置
1、安裝nagios
#tar zxvf tar zxvf nagios-3.2.1.tar.gz
#cd nagios-3.2.1
#./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
#make all
#make install
#make install-init
#make install-config
#make install-commandmode
#make install-webconf //可以自動(dòng)安裝在httpd.conf中的配置,生成nagios.conf;
2、安裝nagios-plugins
#tar zxvf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make
#make install
3、安裝nrpe
#tar zxvf nagios-nrpe_2.8.1.orig.tar.gz
#cd nrpe-2.8.1
#./configure --enable-ssl --with-ssl-lib=/lib/
#rpm -qa | grep ssl 保證:能夠抓到 前兩個(gè)
openssl-0.9.8e-12.el5
openssl-devel-0.9.8e-12.el5
openssl-perl-0.9.8e-12.el5
#make all
#make install-plugin
4、vim 編輯commands.cfg文件定義nrpe對(duì)的使用
#vim /usr/local/nagios/etc/objects/commands.cfg
//添加如下幾行使支持check_nrep
#check_nrep
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
5、配置監(jiān)控對(duì)象(工作站及其服務(wù)等)
#vim /usr/local/nagios/etc/nagios.cfg
//在losthost.cfg下添加
cfg_file=/usr/local/nagios/etc/objects/linux.cfg
6、新建linux.cfg設(shè)置要監(jiān)控的內(nèi)容
#vim /usr/local/nagios/etc/object/linux.cfg
define host{
use linux-server
host_name mylinux //需要修改工作站的主機(jī)名
alias mylinux
address 192.168.0.44 //工作站主機(jī)IP
}
define service{
use generic-service
host_name mylinux
service_description check-swap //對(duì)下面操作的描述
check_command check_nrpe!check_swap //執(zhí)行檢測(cè)交換分區(qū)命令,監(jiān)控swap
}
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load //監(jiān)控負(fù)載
}
define service{
use generic-service
host_name mylinux
service_description check-disk
check_command check_nrpe!check_had1 //監(jiān)控硬盤
}
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users //監(jiān)控用戶(使用)情況
}
define service{
use generic-service
host_name mylinux
service_description otal_procs
check_command check_nrpe!check_total_procs //監(jiān)控進(jìn)程
}
//對(duì)以上的linux.cfg文件編輯如果有錯(cuò),將會(huì)導(dǎo)致nagios無法啟動(dòng);
//修改工作站主機(jī)的主機(jī)名為mylinux,保證能夠#ping mylinux 通信正常,可以選擇
#echo "192.168.0.44 mylinux " >> /etc/hosts
#echo"192.168.0.15 nagios " >> /etc/hosts
//在服務(wù)器端
#echo"192.168.0.15 nagios " >> /etc/hosts
#echo "192.168.0.44 mylinux " >> /etc/hosts
7、準(zhǔn)備啟動(dòng)nagios服務(wù)
#setenforce 0 保證selinux處于關(guān)閉狀態(tài)
#service iptables stop 或者開放80,5666端口(http/nrep)
#chkconfig --add nagios //添加nagios服務(wù)到系統(tǒng)服務(wù)隊(duì)列
#chkconfig nagios on //開機(jī)自動(dòng)啟動(dòng)服務(wù)
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
//檢查nagios的配置文件的正確性
//如果上面有錯(cuò)誤,請(qǐng)檢查系統(tǒng)服務(wù)時(shí)間是否同步,新建的linux.cfg是否有語法錯(cuò)誤!
//在commands.cfg是否添加對(duì)nrep使用等
//保證上述命令爭(zhēng)取執(zhí)行
// 參考:
//Total Warnings: 0
//Total Errors: 0
#service nagios start
3、配置工作站上的nagios-plugin/nrpe等
1、安裝nagios-plugin
#useradd nagios
#passwd nagios
#tar -zxvf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make
#make install
2、改變目錄權(quán)限使nagios用戶能夠訪問
#chown –R nagios.nagios /usr/local/nagios
3、安裝nrpe服務(wù)使之能夠通信
#tar zxvf nagios-nrpe_2.8.1.orig.tar.gz
#cd nagios-nrpe_2.8.1
#./configure --enable-ssl --with-ssl-lib=/usr/lib/
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config
4、配置nrpe信息
#vim /usr/local/nagios/etc/nrpe.cfg
allowed_host=192.168.0.15,127.0.0.1 //允許192.168.0.15服務(wù)器端對(duì)其監(jiān)控
#/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
//檢測(cè)nrep配置文件的正確性
#netstat -an | grep 5666 //是否監(jiān)聽5666用于nrpe通信的端口
//在服務(wù)端執(zhí)行檢測(cè)工作站nrpe信息
#/usr/local/nagios/libexec/check_nrpe -H 192.168.0.44
NRPE v2.8.1
//在工作站執(zhí)行檢測(cè)自己的nrpe信息
#/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v2.8.1
5、配置工作站上的被檢測(cè)上網(wǎng)信息
#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_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%
分享標(biāo)題:nagios_server和client(nagios監(jiān)控)
文章路徑:http://jinyejixie.com/article28/peocjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、靜態(tài)網(wǎng)站、Google、自適應(yīng)網(wǎng)站、App開發(fā)、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)