Centos6.5安裝Nagios4.02+Centreon-2.5.0

一、系統環境:php

Centos6.5 x64
Nagios 4.0.2
Centreon-2.5.0.tar
nrpe-2.15
ndoutils-1.5.2.tar.gz
--------------------
二、下載軟件包

wKiom1MKJlKj8_2FAAEC26fRst8361.jpg


[root@lianglab ~]# cd /usr/local/src/
[root@lianglab src]# ls
三、更新yum源,安裝centreon所須要的環境
須要添加RPM forge資料庫
[root@lianglab src]# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
[root@lianglab src]# rpm --import RPM-GPG-KEY.dag.txt
[root@lianglab src]# rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Preparing...                ########################################### [100%]
  1:rpmforge-release       ########################################### [100%]

[root@lianglab src]# html

如今你要作好安裝前的準備。
#yum update
#yum upgrade


安裝依賴包和Apache服務器
2.安裝GD庫相關
#yum install gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD
3.安裝mysql庫相關
#yum -y install openssl-devel perl-DBD-MySQL mysql-server mysql-devel
4.安裝PHP及擴展
#yum -y install php php-mysql php-gd php-ldap php-xml php-mbstring
5.安裝PERL及擴展模塊
#yum -y install perl-DBI perl-DBD-MySQL
#yum -y install perl-Config-IniFiles
6.安裝RRDTools相關
#yum -y install rrdtool perl-rrdtool
7.安裝SNMP相關
#yum -y install perl-Crypt-DES perl-Digest-SHA1 perl-Digest-HMAC net-snmp-utils
#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
8.安裝其餘相關依賴庫
#yum -y install fping cpp gcc gcc-c++ libstdc++ glib2-devel
#yum -y install fping
#yum -y install php-process php-devel
9.安裝PEAR相關
#yum -y install php-pear php-pear-DB
#pear  channel-update pear.php.net
[root@lianglab src]# pear channel-update pear.php.net
No log handling enabled - turning on stderr logging
Created directory: /var/lib/net-snmp/mib_indexes
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded
[root@lianglab src]#
#pear upgrade-all
[root@lianglab src]# pear upgrade-all
Will upgrade channel://pear.php.net/xml_rpc
Will upgrade channel://pear.php.net/archive_tar
Will upgrade channel://pear.php.net/console_getopt
WARNING: "pear/XML_RPC" is deprecated in favor of "pear/XML_RPC2"
WARNING: "pear/Console_Getopt" is deprecated in favor of "pear/Console_GetoptPlus"
downloading XML_RPC-1.5.5.tgz ...
Starting to download XML_RPC-1.5.5.tgz (31,862 bytes)
.........done: 31,862 bytes
downloading Archive_Tar-1.3.11.tgz ...
Starting to download Archive_Tar-1.3.11.tgz (18,537 bytes)
...done: 18,537 bytes
downloading Console_Getopt-1.3.1.tgz ...
Starting to download Console_Getopt-1.3.1.tgz (4,471 bytes)
...done: 4,471 bytes
upgrade-all ok: channel://pear.php.net/XML_RPC-1.5.5
upgrade-all ok: channel://pear.php.net/Archive_Tar-1.3.11
upgrade-all ok: channel://pear.php.net/Console_Getopt-1.3.1
[root@lianglab src]#
10.檢查基礎包是否所有安裝成功
[root@lianglab src]# rpm -q gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD |grep "not installed"
package libjpeg-devel is not installed
[root@lianglab src]# rpm -q openssl-devel perl-DBD-MySQL mysql-server mysql-devel |grep "not installed"
[root@lianglab src]# rpm -q php php-mysql php-gd php-ldap php-xml php-mbstring |grep "not installed"
[root@lianglab src]# rpm -q perl-DBI perl-DBD-MySQL |grep "not installed"
[root@lianglab src]# rpm -q perl-Config-IniFiles |grep "not installed"
[root@lianglab src]# rpm -q rrdtool perl-rrdtool |grep "not installed"
package perl-rrdtool is not installed===============rrdtool-perl-1.3.8-6.el6.x86_64 already installed
[root@lianglab src]# rpm -q perl-Crypt-DES perl-Digest-SHA1 perl-Digest-HMAC net-snmp-utils |grep "not installed"
[root@lianglab src]# rpm -q perl-Socket6 perl-IO-Socket-INET6 net-snmp net-snmp-libs php-snmp dmidecode lm_sensors #perl-Net-SNMP net-snmp-perl | grep "not installed"
perl-Socket6-0.23-4.el6.x86_64
perl-IO-Socket-INET6-2.56-4.el6.noarch
net-snmp-5.5-49.el6.x86_64
net-snmp-libs-5.5-49.el6.x86_64
php-snmp-5.3.3-27.el6_5.x86_64
dmidecode-2.11-2.el6.x86_64
lm_sensors-3.1.1-17.el6.x86_64
[root@lianglab src]# rpm -q fping cpp gcc gcc-c++ libstdc++ glib2-devel |grep "not installed"
[root@lianglab src]# rpm -q php-pear php-pear-DB |grep "not installed"
package php-pear-DB is not installed--========,php-pear-db-1.7.13-2.el6.rf.noarch already installed
[root@lianglab src]#



====================安裝nagios=====================
1.建立相關用戶及用戶組
[root@lianglab src]# /usr/sbin/useradd -u 288 nagios
[root@lianglab src]# /usr/sbin/groupadd -g 289 nagcmd
[root@lianglab src]# /usr/sbin/usermod -G nagios,nagcmd apache
[root@lianglab src]# tar zxvf  nagios-4.0.2.tar.gz

wKioL1MKJ6fBpNgsAAHaZREmkXg821.jpg

指定安裝目錄以及帳號相關
[root@lianglab src]# cd nagios-4.0.2
[root@lianglab nagios-4.0.2]# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --enable-nanosleep --enable-broker

wKiom1MKKCiRELPOAAMuflR1CxU749.jpg

#make allmysql

wKioL1MKKAOSgmLHAAP3lW3yJNM762.jpg

#make installios

wKiom1MKKCnwlEh7AAJ_GW-_SXM888.jpg

自動安裝啓動腳本和web相關
#make install-init
#make install-commandmode

wKioL1MKKAORXxyzAALSk1hbH_w750.jpg

#make install-configc++

wKiom1MKKCmimwk3AAKiqkg6pEA889.jpg

#make install-webconfweb

wKioL1MKKAST0RbFAAEZ3gW1Qoo768.jpg

wKiom1MKKCnylvPVAAIDxMpJMbE390.jpg


三.安裝nagios-plugins插件
[root@lianglab nagios-4.0.2]# cd /usr/local/src/
[root@lianglab src]# tar zxvf nagios-plugins-1.5.tar.gz

wKioL1MKKG2DAKqxAALvOvmo8rI453.jpg

[root@lianglab src]# cd nagios-plugins-1.5
[root@lianglab nagios-plugins-1.5]#
[root@lianglab nagios-plugins-1.5]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules

[root@lianglab nagios-plugins-1.5]# make allsql

[root@lianglab nagios-plugins-1.5]# make install數據庫


設定web登錄密碼
[root@lianglab nagios-plugins-1.5]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
[root@lianglab nagios-plugins-1.5]# cat /usr/local/nagios/etc/htpasswd.users
nagiosadmin:laowU8TvgioQA
開機自動啓動相關服務
[root@lianglab nagios-plugins-1.5]# chkconfig --add nagios
[root@lianglab nagios-plugins-1.5]# chkconfig httpd on
[root@lianglab nagios-plugins-1.5]# chkconfig mysqld on
啓動mysql
[root@lianglab nagios-plugins-1.5]# /etc/init.d/mysqld restart
設置mysql的密碼
[root@lianglab nagios-plugins-1.5]# /usr/bin/mysqladmin -u root password 'liang123'
[root@lianglab nagios-plugins-1.5]#

檢查nagios配置文件
[root@lianglab nagios-plugins-1.5]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

wKiom1MKKM2yyCMfAAKmhUJnA3E860.jpg


[root@lianglab nagios-plugins-1.5]# /etc/init.d/httpd restart
中止 httpd:                                               [失敗]
正在啓動 httpd:
                                                          [肯定]
[root@lianglab nagios-plugins-1.5]#
[root@lianglab nagios-plugins-1.5]#
[root@lianglab nagios-plugins-1.5]# /etc/init.d/nagios restart
中止 nagios:                                              [失敗]
正在啓動 nagios:                                          [肯定]

[root@lianglab etc]# cat /usr/local/nagios/var/nagios.log
[1389775797] Nagios 4.0.2 starting... (PID=10532)
[1389775797] Local time is Wed Jan 15 16:49:57 CST 2014
[1389775797] LOG VERSION: 2.0
[1389775797] qh: Socket '/usr/local/nagios/var/rw/nagios.qh' successfully initialized
[1389775797] qh: core query handler registered
[1389775797] nerd: Channel hostchecks registered successfully
[1389775797] nerd: Channel servicechecks registered successfully
[1389775797] nerd: Channel opathchecks registered successfully
[1389775797] nerd: Fully initialized and ready to rock!
[1389775797] wproc: Successfully registered manager as @wproc with query handler
[1389775797] wproc: Registry request: name=Core Worker 10537;pid=10537
[1389775797] wproc: Registry request: name=Core Worker 10536;pid=10536
[1389775797] wproc: Registry request: name=Core Worker 10535;pid=10535
[1389775797] wproc: Registry request: name=Core Worker 10534;pid=10534
[1389775800] Successfully launched command file worker with pid 10538
[1389775909] SERVICE ALERT: localhost;HTTP;WARNING;SOFT;1;HTTP WARNING: HTTP/1.1 403 Forbidden - 5237 bytes in 0.001 second response time
[1389775969] SERVICE ALERT: localhost;HTTP;WARNING;SOFT;2;HTTP WARNING: HTTP/1.1 403 Forbidden - 5237 bytes in 0.000 second response time
[1389776029] SERVICE ALERT: localhost;HTTP;WARNING;SOFT;3;HTTP WARNING: HTTP/1.1 403 Forbidden - 5237 bytes in 0.000 second response time
[1389776089] SERVICE ALERT: localhost;HTTP;WARNING;HARD;4;HTTP WARNING: HTTP/1.1 403 Forbidden - 5237 bytes in 0.001 second response time
[root@lianglab etc]#

wKioL1MKKM_hWulJAARhOmwv3HQ253.jpg



修改數據庫文件
[root@lianglab centreon-2.5.0]# vi /etc/my.cnf
添加一行配置
innodb_file_per_table=1
四.安裝nrpe擴展組件
[root@lianglab src]# cd /usr/local/src/
[root@lianglab src]# tar zxvf nrpe-2.15.tar.gz
[root@lianglab src]# cd nrpe-2.15
[root@lianglab nrpe-2.15]# ./configure

wKiom1MKKRWBzFlRAAIkR7Tn9jw349.jpg


(1) 安裝check_nrpe 這個插件
[root@lianglab nrpe-2.15]# make all

[root@lianglab nrpe-2.15]# make install-pluginapache

(2) 安裝deamon
[root@lianglab nrpe-2.15]# make install-daemon

(3) 安裝配置文件
[root@lianglab nrpe-2.15]# make install-daemon-config

(4) 編輯nrpe配置文件
   [root@ lianglab nrpe-2.15]# vim /usr/local/nagios/etc/nrpe.cfg
默認爲allowed_hosts=127.0.0.1 修改成 allowed_hosts=127.0.0.1 10.1.10.132

wKioL1MKKR6gyYRoAABtwcFqzOo964.jpg

5) 啓動nrpe
[root@lianglab nrpe-2.15]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@lianglab nrpe-2.15]#
6) 查看NRPE 是否已經啓動
[root@lianglab nrpe-2.15]# netstat -nltp | grep nrpe
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      14461/nrpe          
tcp        0      0 :::5666                     :::*                        LISTEN      14461/nrpe          
[root@lianglab nrpe-2.15]#
7) 測試NRPE 是不然正常工做
以前安裝了check_nrpe 這個插件用於測試,如今就是用的時候.執行
[root@lianglab nrpe-2.15]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v2.15
[root@lianglab nrpe-2.15]# /usr/local/nagios/libexec/check_users -w 5 -c 10
USERS OK - 4 users currently logged in |users=4;5;10;0
[root@lianglab nrpe-2.15]#
[root@lianglab nrpe-2.15]# /usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0;


五.安裝ndoutils數據庫插件
[root@lianglab src]# tar zxvf ndoutils-1.5.2.tar.gz
[root@lianglab src]# cd ndoutils-1.5.2
[root@lianglab ndoutils-1.5.2]# ./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios

[root@lianglab ndoutils-1.5.2]# makevim

[root@lianglab ndoutils-1.5.2]# make install


複製配置文件
[root@lianglab ndoutils-1.5.2]# cat config/ndo2db.cfg-sample|grep lock_file
lock_file=/usr/local/nagios/var/ndo2db.lock
[root@lianglab ndoutils-1.5.2]#
[root@lianglab ndoutils-1.5.2]# cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
[root@lianglab ndoutils-1.5.2]# cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
[root@lianglab ndoutils-1.5.2]# cp ./config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
[root@lianglab ndoutils-1.5.2]# cp src/ndomod-3x.o /usr/local/nagios/bin/
[root@lianglab ndoutils-1.5.2]# cp src/ndo2db-3x /usr/local/nagios/bin/
[root@lianglab ndoutils-1.5.2]# chmod 774 /usr/local/nagios/bin/ndo*
[root@lianglab ndoutils-1.5.2]# chown nagios:nagios /usr/local/nagios/bin/ndo*
[root@lianglab ndoutils-1.5.2]# chown nagios:nagios /usr/local/nagios/etc/ndo*
[root@lianglab ndoutils-1.5.2]# cp ./daemon-init /etc/init.d/ndo2db
[root@lianglab ndoutils-1.5.2]# chmod +x /etc/init.d/ndo2db
[root@lianglab ndoutils-1.5.2]#
配置開機自動啓動
[root@lianglab ndoutils-1.5.2]# chkconfig --add ndo2db
[root@lianglab ndoutils-1.5.2]# chkconfig --level 345 ndo2db on
[root@lianglab ndoutils-1.5.2]# /etc/init.d/ndo2db start
ndo2db already started...
[root@lianglab ndoutils-1.5.2]#
[root@lianglab ndoutils-1.5.2]# /etc/init.d/ndo2db status
ndo2db (pid 19162) is running...
[root@lianglab ndoutils-1.5.2]#
[root@lianglab ndoutils-1.5.2]# ps -ef | grep ndo2db
nagios   19162     1  0 19:49 ?        00:00:00 /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
root     19181 14645  0 19:49 pts/3    00:00:00 grep ndo2db
[root@lianglab ndoutils-1.5.2]#

-=======================六.安裝entreon=================

[root@lianglab ndoutils-1.5.2]# cd /usr/local/src/
[root@lianglab src]# tar zxvf centreon-2.5.0.tar.gz

[root@lianglab src]# cd centreon-2.5.0
[root@lianglab centreon-2.5.0]# sh install.sh -i

wKioL1MKK2Phzg-uAAJYr7lrMjM904.jpg

GPL許可證讀完後必須選擇y
肯定安裝centreon幾部分模塊,所有填寫y

wKiom1MKK4iS9GSSAAHA9nwgkao808.jpg

安裝CentWeb
Centreon etc directory更改成/usr/local/centreon/etc
其餘選擇回車和y默認

wKioL1MKK2PRs_oUAAJpYXfjBSo961.jpg

Centreon etc directory更改成/usr/local/centreon/etc
Centreon variable library更改成/usr/local/centreon/var/lib
其餘選擇回車和y默認

wKiom1MKK4mTsf2dAAHUEL3Z7kg510.jpg


選擇回車和y默認
RRD perl module installed [PEAR.php]注意選擇實際路徑
修改成/usr/share/pear/PEAR.php

wKioL1MKK2PgOgiPAAGV3060WGk225.jpg

wKioL1MKK2OBPXqHAAH6sPSVlpk227.jpg

Centreon user and group
Monitoring engine user填寫爲nagios
Broker user ? (optional)填寫爲nagios(就是NDOUtils:)
注意修改默認日誌路徑
Monitoring engine log directory填寫爲/usr/local/nagios/var
monitoring plugins (libexec) directory填寫爲/usr/local/nagios/libexec
填寫nagios啓動腳本全路徑Monitoring engine init.d script
配置爲/etc/init.d/nagios
Monitoring engine binary配置爲/usr/local/nagios/bin/nagios
Monitoring engine configuration directory配置爲/usr/local/nagios/etc


wKiom1MKK4mxArYcAANzmYfa_JE817.jpg

wKioL1MKK2SADF5FAANzmYfa_JE590.jpg

wKiom1MKK4nhvIMvAAJ-NKQVsb0538.jpg

wKioL1MKK2bD3LdDAAJTTCsoNo8991.jpg

wKiom1MKK4yhvYEqAAOGCOuG8TQ342.jpg

wKiom1MKK4ygIJZbAALU0gPUA_0003.jpg

wKioL1MKK2ez80bQAAH53WK4lJM132.jpg

wKioL1MKK2fhthD2AAJvdYzdO_Y966.jpg

wKiom1MKK43A5bLbAAMfs0CVIi8004.jpg

wKioL1MKK2eSXXLZAALKKPsUlLA410.jpg

至此2.5安裝完畢,須要進行web頁面配置,初始化數據庫。
接下來就是頁面配置部署了
安裝歡迎界面,點next下一步


wKiom1MKLYmAOfkfAADpLwxKlP8560.jpg

基本環境檢查,通常檢測經過纔可繼續安裝,點擊next

wKioL1MKLWODKNBTAAE2I9oYEfs201.jpg

安裝監控組件,選擇nagios.配置爲
/usr/local/nagios
/usr/local/nagios/bin/nagiostats
/usr/local/nagios/share/p_w_picpaths

wKiom1MKLYnRPHRRAAF2QcaV7I4174.jpg

選擇代理模塊
配置爲/usr/local/nagios/bin/ndomod.o

wKioL1MKLWSyTYFhAAEWT_VYIPQ339.jpg

設置管理員密碼和郵箱,所有必填。

wKioL1MKLWSh47u7AAFAFDo1KIY098.jpg

配置數據庫,填寫mysql的root密碼和應用庫密碼。

wKiom1MKLYmgzUZiAAHhd04R-Os707.jpg

若是上面配置沒問題的,就初始化數據庫等相關配置

wKioL1MKLWTh_07fAAFi8aSBgeE629.jpg

wKiom1MKLYqTY3r-AAFrtbQvTp0493.jpg

自動跳轉到2.5.0登錄歡迎界面。

wKioL1MKLWShSmnWAACcykVutTo218.jpg

登錄後正常應該先選擇nagios生成配置文件,如今頁面沒有直接寫明nagios配置項了。
找到以下菜單
Configuration-->Monitoring Engines-->Generate
選擇Export導出默認配置,正常狀況應該是OK。

5個選項全勾選上,選擇Export導出配置文件以及覆蓋文件和重啓nagios:

wKiom1MKLhzzVhvLAAM2iTVIaco805.jpg


導出配置和重啓服務正常

wKiom1MKLY_ymG7xAAHPiqvYjDc438.jpg

查看nagios的etc目錄是否是新增長了不少配置文件:
#ls -al /usr/local/nagios/etc/

wKioL1MKLWnhjiooAAaGXHmtD8Y454.jpg

重啓相關服務:
[root@lianglab centreon-2.5.0]# /etc/init.d/centcore start
Starting centcore:                                         [肯定]
[root@lianglab centreon-2.5.0]# /etc/init.d/centstorage start
Starting centstorage:                                      [肯定]
[root@lianglab centreon-2.5.0]# /etc/init.d/ndo2db stop
Stopping ndo2db: head: 沒法打開"/usr/local/nagios/var/ndo2db.lock" 讀取數據: 沒有那個文件或目錄
done.
[root@lianglab centreon-2.5.0]# /etc/init.d/ndo2db start
Starting ndo2db: done.
[root@lianglab centreon-2.5.0]#
點擊 Configuration-->Centreon-->Pollers查看
這樣Pollers就能看到進程號了

處處,Centos6.5下安裝Nagios4.02+Centreon-2.5.0監控環境搭建完成。        


參考文獻:http://blog.sina.com.cn/s/blog_541a3cf10101hjth.html

相關文章
相關標籤/搜索