centreon作为nagios的分布式监控管理平台,其功能强大,打造了centreon在IT监控方面强势地位,它的底层使用nagios监控软件,nagios通过ndoutil模块将监控数据写入数据库,centreon读取该数据并即时的展现监控信息,通过centreon可以简单地管理和配置所有nagios,因此,完全可以使用centreon轻易的搭建企业级分布式IT基础运维监控系统。(百度百科)


    一、安装系统环境,软件版本

操作系统:centos6.5

nagios:4.0.4

nagios-plugins: 2.0

nrpe:2.15

ndoutils:2.0.0

centreon:2.5.0

关闭iptables,selinux


二、服务器安装部署centreon

1、安装依赖环境(建议安装好yum源rpmforge)

    安装GD库相关

    #yum -y install gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD

    安装mysql相关

    #yum -y install openssl-devel perl-DBD-MySQL mysql-server mysql-devel

    安装PHP及扩展

    #yum -y install php php-mysql php-gd php-ldap php-xml php-mbstring php-snmp 

    安装PERL及扩展模块

    #yum -y install perl-DBI perl-Config-IniFiles perl-devel  perl-IO-Socket-INET6 perl-Time-HiRes

    安装RRDtools相关

    #yum -y install rrdtool rrdtool-perl

    安装SNMP相关

    #yum -y install perl-Crypt-DES perl-Digest-SHA1 perl-Digest-HMAC net-snmp* lm_sensors perl-Net-SNMP 

    安装其他相关依赖库 

    #yum -y install fping cpp gcc gcc-c++ libstdc++ glib2-devel

    #yum -y install fping php-process php-devel mail*

    安装PEAR相关

    #yum -y install php-pear php-pear-DB

    #pear channel-update pear.php.net

    #pear upgrade-all


2、安装nagios

    创建用户、用户组

    #groupadd nagcmd

    #useradd -G nagcmd nagios

    #usermod -a -G nagcmd apache

    编译安装

    #tar -zxvf nagios-4.0.4.tar.gz 

    #cd nagios-4.0.4

    #./configure  --prefix=/usr/local/nagios  

                  --with-command-group=nagcmd 

                  --enable-event-broker              #########添加NDoutils############

                  --enable-embedded-perl

    #make all

    #make install  

    #make install-init 

    #make install-config 

    #make install-commandmode 

    #make install-webconf                           #########打开nagios的web接口########

    #chkconfig nagios on

    #service nagios start


   3、安装nagios-plugins 

    #tar -zxvf nagios-plugins-2.0.tar.gz 

    #cd nagios-plugins-2.0

    #./configure   --with-nagios-user=nagios 

                   --with-nagios-group=nagios 

                   --enable-perl-modules

    #make 

    #make install


   4、安装nrpe

    #tar -zxvf nrpe-2.15.tar.gz 

    #cd nrpe-2.15

    #./configure --with-nrpe-user=nagios

                 --with-nrpe-group=nagios

                 --with-nagios-user=nagios

                 --with-nagios-group=nagios

                 --enable-command-args            

    #make all

    #make install-plugin

    #make install-daemon

    #make install-daemon-config


   5、安装ndoutils

    #tar -zxvf ndoutils-2.0.0.tar.gz 

    #cd ndoutils-2.0.0

    #./configure  --prefix=/usr/local/nagios

                  --enable-mysql

                  --with-ndo2db-user=nagios

                  --with-ndo2db-group=nagios

    #make

    #make install

    #cp  config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg #######当前目录为ndoutils-2.0.0#######

    #cp  config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg #######当前目录为ndoutils-2.0.0#######

    #cp  daemon-init /etc/init.d/ndo2db                            #######当前目录为ndoutils-2.0.0#######

    # vim /etc/init.d/ndo2db

      killproc_ndo2db ()

    {

      kill `pidof ndo2db |cut -f1 -d " "` >/dev/null 2>&1 #######重复两行######

      kill `pidof ndo2db |cut -f1 -d " "` >/dev/null 2>&1

     }


     stop)


     echo "Stopping $servicename..."

     killproc_ndo2db

  

     ;;

    #chmod +x /etc/init.d/ndo2db

    #chkconfig --add ndo2db

    #chkconfig  ndo2db on

至此nagios的作用组件安装完成


6、安装centreon

    #tar -zxvf centreon-2.5.0.tar.gz 

    #cd centreon-2.5.0

    #./install.sh -i

    此过程为交互式,只需按要求填写路径即可。(附件为安装过程截图)


    7、启动web前准备

    #service httpd restart

    #chkconfig httpd on

    #service mysqld start

    #chkconfig mysqld on

    #mysqladmin -u root -p'' 

    #vim /etc/my.cnf

    [mysqld]

    innodb_file_per_table=1        ####为每个innodb表格创建独立表空间

    #service mysqld restart


    8、web页面安装

    附件截图


    9、启动服务

    #service centcore start

    #service centstorage start

    #service centreontrapd start

    #service nagios reload

    #service ndo2db start

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

 

    10、安装汉化

    #wget http://cacti-nagios.googlecode.com/files/messages.mo

    #mkdir -p /usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/

    #cp messages.mo /usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/

    #chown apache:apache -R /usr/local/centreon/www/locale

    #Administration -> admin -> Language选择zh_CN,设置完成后重新登陆(web页面设置)

    至此服务器端安装完成


   三、客户端安装

   1、安装依赖

    #yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel perl-CPAN openssl-devel net-snmp*

    

    2、安装nagios-plugins

    #tar -zxvf nagios-plugins-2.0.tar.gz 

    #cd nagios-plugins-2.0

    #./configure   --with-nagios-user=nagios 

                   --with-nagios-group=nagios 

                   --enable-perl-modules

    #make 

    #make install


    3、安装nrpe

    #tar -zxvf nrpe-2.15.tar.gz 

    #cd nrpe-2.15

    #./configure --with-nrpe-user=nagios

                 --with-nrpe-group=nagios

                 --with-nagios-user=nagios

                 --with-nagios-group=nagios

                 --enable-command-args            

    #make all

    #make install-plugin

    #make install-daemon

    #make install-daemon-config


    4、修改nrpe配置文件

    #vim /usr/local/nagios/etc/nrpe

    allowed_hosts=127.0.0.1,serverip

    allowed_hosts=127.0.0.1,172.16.30.11(逗号两边不能有空格)

    启动nrpe服务

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


    5、验证服务器、客户端通信

    在服务器端执行

    #/usr/local/nagios/libexec/check_nrpe -H 172.16.30.10(客户端ip)

    NRPE v2.15

    则表示通信正常


至此centreon安装完成