天天看點

nagios安裝

###############緒論#############################################################################

nagios是一款開源監控軟體,運作在LINUX/UNIX平台,其配置檔案複雜關聯性,網上給了一個美名"難夠死"。

早期2.X版本,無須安裝PHP,目前新版是3.X,需要PHP的支援。

本文安裝過程是參考的田逸的《網際網路營運智慧》一書,更詳細的可以去檢視。

http://baike.baidu.com/view/5017732.htm

#################################################################################################

##############前提條件########################################################################

nagios是基于LAMP環境(linux+apache+mysql+php)搭建的,是以首先要先把這個環境跑起來,

然後再編譯安裝nagios。

監控端隻需把mysql軟體包傳上去即可,無須安裝,目的是在編譯naigos-plugin時,生成check_mysql指令。

監控端需要安裝 nagios-3.2.1.tar.gz

               nagios-plugins-1.4.14.tar.gz

               nrpe-2.12.tar.gz

被監控端需要安裝 nagios-plugins-1.4.14.tar.gz

                 nrpe-2.12.tar.gz

##############################################################################################

###############涉及的nagios配置檔案################################

nagios.cfg ——主配置檔案,用來修改對象配置檔案

cgi.cfg —— 允許通路nagios網頁平台使用者配置檔案

htpasswd.users —— 登陸nagios網頁平台使用者名和密碼存放的加密檔案

resource.cfg —— 用來存放nagios指令插件配置檔案

nrpe.cfg —— 被監控端監控資源配置檔案

commands.cfg —— 監控指令配置檔案

templates.cfg —— 監控模闆檔案

timeperiods.cfg —— 時間模闆檔案

contacts.cfg —— 故障時通知的聯系人配置檔案

contactgroups.cfg —— 故障時通知的聯系人組配置檔案

hosts —— 監控主機配置檔案

hostgroups —— 監控主機組配置檔案

services —— 監控主機服務配置檔案

####################################################################

##############

###安裝步驟###

##########首先安裝gcc包,用于編譯安裝軟體用################

yum --disablerepo=\* --enablerepo=c5-media  install *gcc*

###########################################################

#############Apache########################################

./configure --prefix=/usr/local/apache --enable-so

make

make install

# vi /usr/local/apache/conf/httpd.conf

AddType application/x-httpd-php .php

Include conf/nagios.conf

######PHP-plugin#########################################

./configure --prefix=/usr/local/libiconv

yum --disablerepo=\* --enablerepo=c5-media  install *freetype* *jpeg* *png* *gd* *libxml*

#########################################################

#############mysql####################

vi /etc/ld.so.conf

/usr/local/mysql/lib

ldconfig -v

vi /root/.bash_profile 

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY '123456';

flush privileges;

######################################

######PHP############################

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir --with-iconv=/usr/local/libiconv --with-config-file-path=/usr/local/php/etc --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-ldap --with-ldap-sasl --with-gettext --enable-mbstring --enable-sockets

make ZEND_EXTRA_LIBS='-liconv'

cp php.ini-dist /usr/local/php/etc/php.ini

############naigos####################

useradd nagios

./configure  --prefix=/usr/local/nagios  --with-command-group=nagios

make all

make install-init

make install-config

make install-commandmode

make install-webconf

([root@vm01 nagios-3.2.1]# make install-webconf

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

/usr/bin/install: 無法建立一般檔案“/etc/httpd/conf.d/nagios.conf”: 沒有那個檔案或目錄

make: *** [install-webconf] 錯誤 1)

mkdir -p /etc/httpd/conf.d/

[root@vm01 nagios-3.2.1]# make install-webconf

*** Nagios/Apache conf file installed ***

/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

chkconfig --add nagios

chkconfig nagios on

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

###########naigos-plugin##############

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios  --with-mysql

make && make install

############nrpe#####################

./configure  --enable-command-args

make install-plugin

make install-daemon

make install-daemon-config

vi nrpe.cfg

dont_blame_nrpe=1

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

/usr/local/nagios/libexec/check_nrpe -H localhost

#######################################

mount -t iso9660 -o loop /home/rhel-server-5.5-x86_64-dvd.iso /var/ftp/pub/

本文轉自 liang3391 51CTO部落格,原文連結:http://blog.51cto.com/liang3391/723513