nagios+centreon監(jiān)控構(gòu)建

監(jiān)控系統(tǒng)是運維人員的一個重要工具,熟悉其的構(gòu)建與應(yīng)用必不可少。nagios與centreon的搭

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計、網(wǎng)站制作、海城網(wǎng)絡(luò)推廣、微信小程序開發(fā)、海城網(wǎng)絡(luò)營銷、海城企業(yè)策劃、海城品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供海城建站搭建服務(wù),24小時服務(wù)熱線:13518219792,官方網(wǎng)址:bm7419.com

配是開源軟件最佳選擇?,F(xiàn)在將我的構(gòu)建與應(yīng)用過程記錄如下。

一.環(huán)境預(yù)安裝

1.獲取主軟件包

wget http://jaist.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz
wget http://download.centreon.com/centreon/centreon-2.4.2.tar.gz
wget http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
wget http://nchc.dl.sourceforge.net/project/nagios/ndoutils-1.x/ndoutils-1.5.2/ndoutils-1.5.2.tar.gz
wget http://svn.centreon.com/trunk/ndoutils-patch/ndoutils1.5.2_light.patch
wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

2.安裝第三方源

[root@localhost ~]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-1.el6.rf.i686.rpm
[root@localhost ~]#rpm -ivh rpmforge-release-0.5.2-1.el6.rf.i686.rpm

如果不安裝第三方源會導(dǎo)致相關(guān)軟件包不能安裝,進而導(dǎo)致主安裝出現(xiàn)相關(guān)問題。

3.安裝相關(guān)軟件包

安裝apache

[root@localhost ~]# yum -y install httpd
[root@localhost ~]# usermod -U apache
[root@localhost ~]# service httpd start

[root@localhost ~]# yum install MySQL-devel openssl-devel mysql-server
[root@localhost ~]# service mysqld start
[root@localhost ~]# mysqladmin -u root password '123456'

在/etc/my.conf中的[mysqld]加入

innodb_file_per_table=1

否則在web安裝第七步時會有提示。

安裝php
[root@localhost ~]# yum -y install php php-mysql php-gd php-ldap php-xml php-mbstring
[root@localhost ~]# yum -y install gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD

RRDTools
[root@localhost ~]# yum -y install rrdtool perl-rrdtool

安裝perl
[root@localhost ~]# yum -y install perl-Config-IniFiles perl-DBI perl-DBD-MySQL

安裝SNMP
[root@localhost ~]# yum -y install perl-Crypt-DES perl-Digest-SHA1 perl-Digest-HMAC net-snmp-utils
[root@localhost ~]# yum -y install perl-Socket6 perl-IO-Socket-INET6 net-snmp net-snmp-libs php-snmp dmidecode lm_sensors perl-Net-SNMP net-snmp-perl


安裝PEAR
[root@localhost ~]# yum -y install php-pear
[root@localhost ~]# pear channel-update pear.php.net
[root@localhost ~]# pear install --force PEAR-1.9.1
[root@localhost ~]# pear upgrade-all

二. 主軟件包安裝

nagios主要監(jiān)控系統(tǒng)與網(wǎng)絡(luò)信息,同時監(jiān)控遠程與本地主機及相關(guān)服務(wù),還提供信息異常功能

1.安裝nagios

添加相關(guān)用戶及組

[root@localhost ~]# useradd -m nagios
[root@localhost ~]# passwd nagios
更改用戶 nagios 的密碼 。
新的 密碼:
無效的密碼: 過于簡單化/系統(tǒng)化
無效的密碼: 過于簡單
重新輸入新的 密碼:
passwd: 所有的身份驗證令牌已經(jīng)成功更新。
[root@localhost ~]# groupadd nagcmd
[root@localhost ~]# usermod -G nagios,nagcmd nagios
[root@localhost ~]# usermod -G nagios,nagcmd apache

安裝nagios

[root@localhost monitor]# tar -zxvf nagios-3.5.0.tar.gz
[root@localhost nagios]# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --enable-nanosleep --enable-event-broker --enable-embedded-perl
[root@localhost nagios]# make all
[root@localhost nagios]# make install
[root@localhost nagios]# make install-init
[root@localhost nagios]# make install-commandmode
[root@localhost nagios]# make install-config
[root@localhost nagios]# /etc/init.d/nagios start

nagios如果少了其插件,將什么也做不了,其功能主要通過插件來完成的。

2.nagios-pluigns安裝

[root@localhost monitor]# tar -zxvf nagios-plugins-1.4.16.tar.gz
[root@localhost nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules
[root@localhost nagios-plugins-1.4.16]# make && make install

3.ndoutils安裝

ndoutils主要將相關(guān)數(shù)據(jù)存儲到數(shù)據(jù)庫,ndoutils非常重要。

[root@localhost ndoutils-1.5.2]# tar -zxvf ndoutils-1.5.2.tar.gz
[root@localhost ndoutils-1.5.2]# patch -p1 -N < ndoutils1.5.2_light.patch
[root@localhost ndoutils-1.5.2]# ./configure --prefix=/usr/local/nagios/ --enable-mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
[root@localhost ndoutils-1.5.2]# make && make install
[root@localhost ndoutils-1.5.2]# cp daemon-init /etc/init.d/ndo2db
[root@localhost ndoutils-1.5.2]# chmod 755 /etc/init.d/ndo2db
[root@localhost ndoutils-1.5.2]# cp config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
[root@localhost ndoutils-1.5.2]# /etc/init.d/ndoutils start

4.centreon安裝

centreon以web方式展現(xiàn)給用戶,通過第三方軟件實現(xiàn)對網(wǎng)絡(luò),應(yīng)用程序,主機的監(jiān)控。

注:如下安裝過程只做參考,其不是第一次安裝 ,與第一次安裝可能有所不同,第一次安裝時會更新相關(guān)模塊。

文本安裝

[root@localhost monitor]# tar -zxvf centreon-2.4.2.tar.gz


[root@localhost centreon-2.4.2]# ./install.sh -i
###############################################################################
# #
# Centreon (www.centreon.com) #
# Thanks for using Centreon #
# #
# v2.4.2 #
# #
# infos@centreon.com #
# #
# Make sure you have installed and configured #
# sudo - sed - php - apache - rrdtool - mysql #
# #
###############################################################################
------------------------------------------------------------------------
Checking all needed binaries
------------------------------------------------------------------------
rm OK
cp OK
mv OK
/bin/chmod OK
/bin/chown OK
echo OK
more OK
mkdir OK
find OK
/bin/grep OK
/bin/cat OK
/bin/sed OK

You will now read Centreon Licence.
Press enter to continue.
Do you accept GPL license ?
[y/n], default to [n]:
> y
------------------------------------------------------------------------
Please choose what you want to install
------------------------------------------------------------------------

Do you want to install : Centreon Web Front
[y/n], default to [n]:
> y

Do you want to install : Centreon CentCore
[y/n], default to [n]:
> y

Do you want to install : Centreon Nagios Plugins
[y/n], default to [n]:
> y

Do you want to install : Centreon Snmp Traps process
[y/n], default to [n]:
> y

------------------------------------------------------------------------
Start CentWeb Installation
------------------------------------------------------------------------

Where is your Centreon directory?
default to [/usr/local/centreon]
>

Do you want me to create this directory ? [/usr/local/centreon]
[y/n], default to [n]:
> y
Path /usr/local/centreon OK

Where is your Centreon log directory
default to [/usr/local/centreon/log]
>

Do you want me to create this directory ? [/usr/local/centreon/log]
[y/n], default to [n]:
> y
Path /usr/local/centreon/log OK

Where is your Centreon etc directory
default to [/etc/centreon]
> /usr/local/centreon/etc

Do you want me to create this directory ? [/usr/local/centreon/etc]
[y/n], default to [n]:
> y
Path /usr/local/centreon/etc OK

Where is your Centreon binaries directory
default to [/usr/local/centreon/bin]
>

Do you want me to create this directory ? [/usr/local/centreon/bin]
[y/n], default to [n]:
> y
Path /usr/local/centreon/bin OK

Where is your Centreon data informations directory
default to [/usr/local/centreon/data]
>

Do you want me to create this directory ? [/usr/local/centreon/data]
[y/n], default to [n]:
> y
Path /usr/local/centreon/data OK

Where is your Centreon generation_files directory?
default to [/usr/local/centreon]
>
Path /usr/local/centreon OK

Where is your Centreon variable library directory?
default to [/var/lib/centreon]
> /usr/local/centreon/var/lib

Do you want me to create this directory ? [/usr/local/centreon/var/lib]
[y/n], default to [n]:
> y
Path /usr/local/centreon/var/lib OK

Where is your CentPlugins Traps binary
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin OK

Where is the RRD perl module installed [RRDs.pm]
default to [/usr/lib/perl5/RRDs.pm]
>
Path /usr/lib/perl5 OK
/usr/bin/rrdtool OK
/bin/mail OK
/usr/bin/php OK

Where is PEAR [PEAR.php]
default to [/usr/share/php/PEAR.php]
> /usr/share/pear/PEAR.php
Path /usr/share/pear OK
/usr/bin/perl OK
Finding Apache user : apache
Finding Apache group : apache

What is the Centreon group ? [centreon]
default to [centreon]
>

What is the Centreon user ? [centreon]
default to [centreon]
>

What is the Monitoring engine user ?
> nagios

What is the Broker user ? (optional)
> nagios

What is the Monitoring engine log directory ?
>/usr/local/nagios/var/

Where is your monitoring plugins (libexec) directory ?
default to [/usr/lib/nagios/plugins]
> /usr/local/nagios/libexec
Path /usr/local/nagios/libexec OK
Add group centreon to user apache OK
Add group centreon to user nagios OK
Add group nagios to user apache OK
Add group nagios to user centreon OK

------------------------------------------------------------------------
Configure Sudo
------------------------------------------------------------------------

Where is sudo configuration file
default to [/etc/sudoers]
>
/etc/sudoers OK

What is the Monitoring engine init.d script ?
>/etc/init.d/nagios

What is the Monitoring engine binary ?
> /usr/local/nagios/bin/nagios

What is the Monitoring engine configuration directory ?
> /usr/local/nagios/etc/

Where is the configuration directory for broker module ?
> /usr/local/nagios/etc/

Where is the init script for broker module daemon ?
> /etc/init.d/ndo2db
Your sudo has been configured previously

Do you want me to reconfigure your sudo ? (WARNING)
[y/n], default to [n]:
> y
Configuring Sudo OK

------------------------------------------------------------------------
Configure Apache server
------------------------------------------------------------------------
Finding Apache Centreon configuration file
'/etc/httpd/conf.d/centreon.conf' : OK

Do you want to update Centreon Apache sub configuration file ?
[y/n], default to [n]:
> y
Backup Centreon Apache configuration completed
Create '/etc/httpd/conf.d/centreon.conf' OK
Configuring Apache OK

Do you want to reload your Apache ?
[y/n], default to [n]:
> y
Reloading Apache service OK
Preparing Centreon temporary files
Change right on /usr/local/centreon/log OK
Change right on /usr/local/centreon/etc OK
Change macros for insertBaseConf.sql OK
Change macros for sql update files OK
Change macros for php files OK
Change right on /usr/local/nagios/etc OK
Add group nagios to user apache OK
Add group nagios to user nagios OK
Add group centreon to user nagios OK
Copy CentWeb in system directory
Install CentWeb (web front of centreon) OK
Change right for install directory
Change right for install directory OK
Install libraries OK
Write right to Smarty Cache OK
Copying libinstall OK
Change macros for centreon.cron OK
Install Centreon cron.d file OK
Change macros for centAcl.php OK
Change macros for downtimeManager.php OK
Change macros for eventReportBuilder.pl OK
Change macros for dashboardBuilder.pl OK
Install cron directory OK
Change right for eventReportBuilder.pl OK
Change right for dashboardBuilder.pl OK
Change macros for centreon.logrotate OK
Install Centreon logrotate.d file OK
Prepare export-mysql-indexes OK
Install export-mysql-indexes OK
Prepare import-mysql-indexes OK
Install import-mysql-indexes OK
Prepare indexes schema OK
Install indexes schema OK

------------------------------------------------------------------------
Pear Modules
------------------------------------------------------------------------
Check PEAR modules
PEAR 1.4.9 1.9.4 OK
DB 1.7.6 1.7.14 OK
DB_DataObject 1.8.4 1.11.2 OK
DB_DataObject_FormBuilder 1.0.0RC4 1.0.2 OK
MDB2 2.0.0 2.4.1 OK
Date 1.4.6 1.4.7 OK
HTML_Common 1.2.2 1.2.5 OK
HTML_QuickForm 3.2.5 3.2.13 OK
HTML_QuickForm_advmultiselect 1.1.0 1.5.1 OK
HTML_Table 1.6.1 1.8.3 OK
Archive_Tar 1.1 1.3.11 OK
Auth_SASL 1.0.1 1.0.6 OK
Console_Getopt 1.2 1.3.1 OK
Net_SMTP 1.2.8 1.6.1 OK
Net_Socket 1.0.1 1.0.10 OK
Net_Traceroute 0.21 0.21.3 OK
Net_Ping 2.4.1 2.4.5 OK
Validate 0.6.2 0.8.5 OK
XML_RPC 1.4.5 1.5.5 OK
SOAP 0.10.1 0.13.0 OK
Log 1.9.11 1.12.7 OK
Archive_Zip 0.1.2 0.1.2 OK
All PEAR modules OK

------------------------------------------------------------------------
Centreon Post Install
------------------------------------------------------------------------
Create /usr/local/centreon/www/install/install.conf.php OK
Create /usr/local/centreon/etc/instCentWeb.conf OK

------------------------------------------------------------------------
Start CentStorage Installation
------------------------------------------------------------------------

Where is your Centreon Run Dir directory?
default to [/var/run/centreon]
>/usr/local/centreon/var/run

Do you want me to create this directory ? [/usr/local/centreon/var/run]
[y/n], default to [n]:
> y
Path /usr/local/centreon/var/run OK

Where is your CentStorage binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin OK

Where is your CentStorage RRD directory
default to [/var/lib/centreon]
>/usr/local/centreon/var/lib
Path /usr/local/centreon/var/lib OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
install www/install/createTablesCentstorage.sql OK
Creating Centreon Directory '/usr/local/centreon/var/lib/stOKus'
Creating Centreon Directory '/usr/local/centreon/var/lib/meOKics'
Change macros for centstorage binary OK
Install CentStorage binary OK
Install library for centstorage OK
Change right : /usr/local/centreon/var/run OK
Change macros for centstorage init script OK

Do you want me to install CentStorage init script ?
[y/n], default to [n]:
> y
CentStorage init script installed OK

Do you want me to install CentStorage run level ?
[y/n], default to [n]:
> y
Change macros for logAnalyser OK
Install logAnalyser OK
Change macros for logAnalyser-cbroker OK
Install logAnalyser-cbroker OK
Change macros for nagiosPerfTrace OK
Install nagiosPerfTrace OK
Change macros for purgeLogs OK
Install purgeLogs OK
Change macros for purgeCentstorage OK
Install purgeCentstorage OK
Change macros for centreonPurge.sh OK
Install centreonPurge.sh OK
Change macros for centstorage.cron OK
Install CentStorage cron OK
Change macros for centstorage.logrotate OK
Install Centreon Storage logrotate.d file OK
Create /usr/local/centreon/etc/instCentStorage.conf OK

------------------------------------------------------------------------
Start CentCore Installation
------------------------------------------------------------------------

Where is your CentCore binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin OK
/usr/bin/ssh OK
/usr/bin/scp OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change CentCore Macro OK
Copy CentCore in binary directory OK
Change right : /usr/local/centreon/var/run OK
Change right : /usr/local/centreon/var/lib OK
Change macros for centcore.logrotate OK
Install Centreon Core logrotate.d file OK
Replace CentCore init script Macro OK
Do you want me to install CentCore init script ?
[y/n], default to [n]:
> y
CentCore init script installed OK

Do you want me to install CentCore run level ?
[y/n], default to [n]:
> y
Create /usr/local/centreon/etc/instCentCore.conf OK

------------------------------------------------------------------------
Start CentPlugins Installation
------------------------------------------------------------------------

Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]
> /usr/local/centreon/var/lib/centplugins/

Do you want me to create this directory ? [/usr/local/centreon/var/lib/centplugins/]
[y/n], default to [n]:
> y
Path /usr/local/centreon/var/lib/centplugins/ OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for CentPlugins OK
Installing the plugins OK
Change right on centreon.conf OK
CentPlugins is installed

------------------------------------------------------------------------
Start CentPlugins Traps Installation
------------------------------------------------------------------------

Where is your SNMP configuration directory
default to [/etc/snmp]
>
/etc/snmp OK

Where is your SNMPTT binaries directory
default to [/usr/local/centreon/bin/]
>
/usr/local/centreon/bin/ OK
Finding Apache user : apache
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for CentPluginsTraps OK
Change macros for init scripts OK
Installing the plugins Trap binaries OK
Change macros for snmptrapd.conf OK
Change macros for snmptt.ini OK
SNMPTT init script installed OK
Install : snmptrapd.conf OK
Install : snmp.conf OK
Install : snmptt.ini OK
Install : snmptt OK
Install : snmptthandler OK
Install : snmpttconvertmib OK
Create /usr/local/centreon/etc/instCentPlugins.conf OK
###############################################################################
# #
# Go to the URL : http://localhost/centreon/ #
# to finish the setup #
# #
# Report bugs at http://forge.centreon.com #
# #
# Thanks for using Centreon. #
# ----------------------- #
# Contact : infos@centreon.com #
# http://www.centreon.com #
# #
###############################################################################

web安裝

(1)centreon的歡迎界面

nagios+centreon監(jiān)控構(gòu)建

(2)檢查依賴關(guān)系

nagios+centreon監(jiān)控構(gòu)建

(3)配置nagios信息

nagios+centreon監(jiān)控構(gòu)建

(4)配置ndoutils模塊

nagios+centreon監(jiān)控構(gòu)建

(5)配置admin用戶

nagios+centreon監(jiān)控構(gòu)建

(6)配置數(shù)據(jù)庫信息

nagios+centreon監(jiān)控構(gòu)建

(7)安裝

nagios+centreon監(jiān)控構(gòu)建

(8)安裝完成

nagios+centreon監(jiān)控構(gòu)建

5.服務(wù)器端nrpe安裝

nrpe是nagios組件,能夠執(zhí)行遠程主機的本地檢測腳本,監(jiān)控運行狀態(tài)。

[root@localhost monitor]# tar -zxvf nrpe-2.14.tar.gz
[root@localhost nrpe-2.14]# ./configure
[root@localhost nrpe-2.14]# make all && make install

服務(wù)器端檢測錯誤

[root@nodes01 nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
CHECK_NRPE: Error - Could not complete SSL handshake

在/usr/local/nagios/etc/nrpe.cfg加入

allowed_hosts=127.0.0.1,192.168.4.213

[root@nodes01 nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v2.12
[root@nodes01 nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H 192.168.4.213
NRPE v2.12

三.后續(xù)登錄錯誤

1.錯誤信息

nagios+centreon監(jiān)控構(gòu)建

2.日志信息

25/4/2013 18:36:01 - 25/4/2013 18:36:1 - DBI connect('database=centreon_storage;host=localhost:3306','centreon',...) failed: Access denied for user 'centreon'@'localhost' to database 'centreon_storage' at /usr/local/centreon/bin/logAnalyser line 596

3.解決方法

mysql> grant all on centreon.* to centreon@localhost identified by '123456';
Query OK, 0 rows affected (0.07 sec)

mysql> grant all on centreon_status.* to centreon@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on centreon_storage.* to centreon@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)

成功頁面如下

nagios+centreon監(jiān)控構(gòu)建

四.檢查重新生成配置文件

(1)檢查main.cfg的配置

nagios+centreon監(jiān)控構(gòu)建

(2)檢查ndo2db.cfg的配置

nagios+centreon監(jiān)控構(gòu)建

(3)檢查ndomod.cfg的配置

nagios+centreon監(jiān)控構(gòu)建

(4)生成nagios配置文件

nagios+centreon監(jiān)控構(gòu)建

web頁面重啟完成后,查看nagios相關(guān)日志

[root@localhost ~]# tail -f /usr/local/nagios/var/nagios.log | grep ndomod
[1366898324] ndomod: Successfully connected to data sink. 122 queued items to flush.
[1366898324] ndomod: Successfully flushed 122 queued items to data sink.

如果有以上信息代表成功,因為ndoutils是nagios與centreon的紐帶,必須保證其正常運行。

centreon的服務(wù)器端已經(jīng)配置完成,對于其被監(jiān)控主機上也安裝nagios-plugins和nrpe軟件包,這里就不再重復(fù),centreon的應(yīng)用配置及漢化后續(xù)再出。

網(wǎng)頁名稱:nagios+centreon監(jiān)控構(gòu)建
分享路徑:http://bm7419.com/article16/goeigg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、App開發(fā)外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站策劃品牌網(wǎng)站設(shè)計、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營