1、系统环境:

Centos6.5 x64
Nagios 4.0.2
Centreon-2.5.0.tar
nrpe-2.15
ndoutils-1.5.2.tar.gz
--------------------
2、下载软件包

wKiom1MKJlKj8_2FAAEC26fRst8361.jpg


[root@lianglab ~]# cd /usr/local/src/
[root@lianglab src]# ls
3、更新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]#

现在你要做好安装前的准备。
#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 all

wKioL1MKKAOSgmLHAAP3lW3yJNM762.jpg

#make install

wKiom1MKKCnwlEh7AAJ_GW-_SXM888.jpg

自动安装启动脚本和web相关
#make install-init
#make install-commandmode

wKioL1MKKAORXxyzAALSk1hbH_w750.jpg

#make install-config

wKiom1MKKCmimwk3AAKiqkg6pEA889.jpg

#make install-webconf

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 all

[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-plugin

(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]# make

[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