您好,登錄后才能下訂單哦!
本篇內容主要講解“centos6.2怎么用nagios nrpe監控本地與遠程Linux主機”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“centos6.2怎么用nagios nrpe監控本地與遠程Linux主機”吧!
假設我的監控主機ip是192.168.122.3,遠程被監控主機是192.168.122.14.兩個系統都是centos6.3系統。首先介紹監控本地主機。這部分很簡單,可以參考Nagios 官方指導文檔http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html,下面我只寫操作命令,不多贅述了。
yum -y install httpd httpd-devel php openssl-devel gcc glibc glibc-common gd gd-devel
/usr/sbin/useradd -m nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
wget http://iweb.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.1/nagios-3.4.1.tar.gz
wget http://iweb.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
tar xzf nagios-3.4.1.tar.gz
cd nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
vi /usr/local/nagios/etc/objects/contacts.cfg 修改你的email地址
make install-webconf
為登錄Nagios Web接口創建nagiosadmin帳號。記住下面你設置的密碼,之后登錄用到
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart
安裝Nagios插件
tar xzf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
21. 設置Nagios開機自啟動
chkconfig --add nagios
chkconfig nagios on
22 測試配置文件是否有錯誤
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
23. 如果沒有,就啟動nagios
service nagios start
下面是介紹使用nrpe監控遠程主機
首先是遠程被監控主機的操作
wget http://iweb.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz
wget http://iweb.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
添加nagios 帳號
3. useradd nagios; passwd nagios
安裝nagios-plugin
tar xvfz nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
export LDFLAGS=-ldl
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
make
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec/
安裝nrpe
tar xvfz nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
yum install xinetd
make install-xinetd
更改/etc/xinetd.d/nrpe文件,設置允許nagios服務器連接,如nagios服務器的ip為192.168.122.3
only_from = 127.0.0.1 192.168.122.3
在/etc/services結尾增加
nrpe 5666/tcp # NRPE
啟動xinetd
service xinetd restart
驗證nrpe是否監聽
ss -an | grep 5666
測試nrpe是否正常工作
/usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.13
更改 /usr/local/nagios/etc/nrpe.cfg
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
======================================================================
下面是nagios服務器的操作
wget http://iweb.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz
tar xvfz nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
測試是否正常
/usr/local/nagios/libexec/check_nrpe -H 192.168.122.14
NRPE v2.13
在
在文件/usr/local/nagios/etc/objects/commands.cfg后面增加:
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}
創建/usr/local/nagios/etc/objects/remotehost.cfg
host定義示例:
define host{
use linux-server
host_name defcon
address 192.168.122.14
}
Service定義示例:
define service{
use generic-service
service_description Root Partition
check_command check_nrpe!check_disk
}
然后echo “cfg_file=/usr/local/nagios/etc/objects/remotehost.cfg” >> /usr/local/nagios/etc/nagios.cfg"
service nagisos reload就可以查看到遠程主機和本地主機啦
到此,相信大家對“centos6.2怎么用nagios nrpe監控本地與遠程Linux主機”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。