Nagios備忘之安裝

kumu_linux發表於2012-11-21

###############################################Server端###############################################

----------------

Nagios

----------------

原始碼包地址:http://sourceforge.net/projects/nagios/?source=directory

建立nagios賬號:
# useradd nagios && passwd nagios
# groupadd nagcmd                                                   //nagcmd用於從web介面執行外部命令
# usermod -G nagcmd nagios
# usermod -G nagcmd daemon

安裝nagios:
# tar xf nagios.xx.xx
# ./configure --with-command-group=nagcmd --with-nagios-user=nagios --with-nagios-group=nagios
# make all
# make install
# make install-init                            --> 生成init啟動指令碼
# make install-commandmode    --> 設定相應的目錄許可權
# make install-config                      --> 生成模板配置檔案
# make install-webconf                  --> 生成apache配置檔案

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


# yum install httpd
# cp /etc/httpd/conf/nagios.conf /usr/local/apache2/conf/extra/nagios.conf
# vim /usr/local/apache2/conf/httpd.conf
include conf/extra/nagios.conf

# chkconfig --add nagios
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# /etc/init.d/nagios start

測試:http://IP/nagios/
###############################################Server端###############################################


##########################################Server端和Client端安裝#########################################

安裝nagios外掛
-----------------------
nagios-plugin.xx.xx

-----------------------

原始碼地址:http://sourceforge.net/projects/nagiosplug/

# tar xf nagios-plugin.xx.xx
# cd nagios-plugin.xx.xx
# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
# make && make install

# pwd
/usr/local/nagios/libexec
// 外掛安裝後的檔案

-----------------------

nrpe
監控linux本地主機時,我們可以直接更改配置檔案進行監控,如果需要監控的主機與nagios不在同一機器上,即監控遠端linux主機時,需要藉助NRPE外掛實現。

-----------------------

原始碼地址:http://sourceforge.net/projects/nrpe/?source=directory

# ./configure
# make
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# vim /usr/local/nagios/etc/nrpe.cfg

allowed_hosts=127.0.0.1,192.168.1.20 #逗號隔開,授權Server獲取check_nrpe

# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg ‐d   //啟動
# /usr/local/nagios/libexec/check_nrpe  -H 127.0.0.1   //輸出表示nrpe配置成功
NRPE v2.12

##########################################Server端和Client端安裝#########################################


相關文章