顺德公农庄 发表于 2015-11-23 14:29:53

centreon+nagios安装测试(一…

原文地址:centreon+nagios安装测试(一)-环境搭建作者:改变自己  [简介]
     centreon是开源的IT监控软件,由法国人于2003年开发,最初名为Oreon,并于2005年正式更名为centreon。
    centreon作为nagios的分布式监控管理平台,其功能之强大,打造了centreon在IT监控方面强势地位,它的底层使用nagios监控软件,nagios通过ndoutil模块将监控数据写入数据库,centreon读取该数据并即时的展现监控信息,通过centreon可以简单地管理和配置所有nagios,因此,完全可以使用centreon轻易的搭建企业级分布式IT基础运维监控系统。
    在功能方面,将它与nagios+cacti方式对比,说一下优点:
    1、gui方式添加host,支持hosttemplate与servicestemplate,自动建立关联服务,与nagios+cacti相比配置方便简单。
    2、支持graphtemplate,添加servcie时自动添加graph,不必象nagios+cacti监控与流量图设置2步走。
    3、host监控可以全部采用nrpe方式,不必象nagios+cacti生成流量图必须使用snmp。
    4、支持多节点分布式监控,nagios+cacti的分布式监控现在想起来都头痛。
    5、支持acl权限管理方式,对用户权限限制到菜单项,nagios+cacti一个帐号大家用过时啦。
    6、详细的日志管理功能,日志搜索过滤都支持7、功能模块化管理,想要新功能官方没有怎么办,自己写去。
  
  系统:centos-5.632位
  server:192.168.128.21
  client:192.168.128.22
  
  以下安装过程参考了一位同事及网络上的一些文档~
  一、安装centreon所需环境
  可参考官网:
  http://documentation.centreon.com/01-centreon/centreon_web/documentation/01-setup/installation_from_sources/step_01_-_prerequisites/centos
  1)安装yum源
  wgethttp://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
  wgethttp://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  rpm --importRPM-GPG-KEY.dag.txt
  rpm -Uvhrpmforge-release-0.5.1-1.el5.rf.i386.rpm
  
  2)、yum升级系统软件:
  yum update
  yum upgrade
  
  3)、安装Apache2
  yum install httpd
  usermod -U apache
  
  4)、安装GD库
  yum install gdfontconfig-devel libjpeg-devel libpng-devel gd-develperl-GD
  
  5)、安装mysql
  yum install openssl-develperl-DBD-MySQL mysql-server mysql-devel
  
  6)、安装PHP及扩展
  yum install php php-mysqlphp-gd php-ldap php-xml php-mbstring
  
  7)、安装PERL及扩展模块
  yum installperl-Config-IniFiles perl-DBI perl-DBD-MySQL
  
  8)、安装RRDTools
  yum install rrdtoolperl-rrdtool
  
  9)、安装SNMP
  yum install perl-Crypt-DESperl-Digest-SHA1 perl-Digest-HMAC net-snmp-utils
  yum install perl-Socket6perl-IO-Socket-INET6 net-snmp net-snmp-libs
  yum install php-snmpdmidecode lm_sensors perl-Net-SNMP net-snmp-perl
  
  10)、安装其他所需库
  yum install fping cpp gccgcc-c++ libstdc++ glib2-devel
  
  11)、安装PEAR
  yum installphp-pear
  pear channel-updatepear.php.net
  pear upgrade-all
  
  二、server端服务安装
  1)、安装nagios
  #useraddnagios
  #groupaddnagcmd
  #usermod -Gnagios,nagcmd nagios
  #cd/usr/local/src/
  #tar zxfnagios-3.4.1.tar.gz
  #cdnagios
  #./configure --prefix=/usr/local/nagios --with-command-group=nagcmd--enable-nanosleep --enable-event-broker--enable-embedded-perl
  #makeall
  #makeinstall
  #makeinstall-init
  #makeinstall-commandmode
  #makeinstall-config
  #makeinstall-webconf
  #cd../
  
  2)、安装nagios-plugins
  #tar zxfnagios-plugins-1.4.16.tar.gz
  #cdnagios-plugins-1.4.16
  #./configure --with-nagios-user=nagios--with-nagios-group=nagios --with-openssl=/usr/bin/openssl--enable-perl-modules
  #make
  #make install
  #cd ../
  
  3)、安装nrpe
  #tar zxfnrpe-2.13.tar.gz
  #cdnrpe-2.13
  #./configure
  #make all
  #make install-plugin
  #make install-daemon
  #make install-daemon-config
  #cd../
  
  4)、安装ndoutils
  # tar zxfndoutils-1.5.2.tar.gz
  # cdndoutils-1.5.2
  # ./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
  # cp ./config/ndomod.cfg-sample/usr/local/nagios/etc/ndomod.cfg
  # cp daemon-init /etc/init.d/ndo2db
  # vi /etc/init.d/ndo2db
  killproc_ndo2db()
  {
         kill `pidof ndo2db |cut -f1 -d " "` >/dev/null2>&1      //重复两行
         kill `pidof ndo2db |cut -f1 -d " "` >/dev/null2>&1
  }
  
  stop)
  
         echo "Stopping $servicename..."
         killproc_ndo2db
                 ;;
  # chmod +x /etc/init.d/ndo2db
  # chkconfig --add ndo2db
  # chkconfig --level 345 ndo2db on
  # cd ../
  
  5)、安装centreon
  # tar zxfcentreon-2.3.8.tar.gz
  # cdcentreon-2.3.8
  # ./install.sh –i
  以下是安装过程全部截图:
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
GPL许可证,填写y
  确定安装centreon几部分模块,全部填写y
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
Centreon etcdirectory更改为/usr/local/centreon/etc
  Centreon variable librarydirectory更改为/usr/local/centreon/var/lib
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
RRD perl module installed更改为/usr/lib/perl5/vendor_perl/5.8.8/RRDp.pm
  (可以通过rpm -ql perl-rrdtool确认,最好验证,不一定是上面的路径)
  PEAR更改为/usr/share/pear/PEAR.php
  (可以通过rpm -ql php-pear确认)
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
NDO ndomodbinary更改为/usr/local/nagios/bin/ndomod.o
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
配置sudo
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
配置apache
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
更新pear模块
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
所有模块更新OK
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
Centreon Run Dirdirectory更改为/usr/local/centreon/var/run
  CentStorage RRDdirectory更改为/usr/local/centreon/var/lib
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
继续centstorage安装
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
centcore安装
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
CentPlugins lib directory更改为/usr/local/centreon/var/lib/centplugins
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
centplugintraps安装,安装完成。
  
  6)、启动相关服务
  # cd
  #/etc/init.d/httpd start
  #/etc/init.d/mysqld start
  #mysqladmin -u root password '111111'
  #/etc/init.d/ndo2db start
  
  7)、WEB界面安装
  浏览器输入:http://192.168.128.21/centreon
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
点击start
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
选择Iaccpet,点击Next
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
默认环境配置
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
检验PHP配置
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
检验PHP配置
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
Mysqlroot密码:填入上面初始化密码,centon三个库及密码:自定义
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
Mysql检查
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
配置centon管理员用户、密码,其他三项自定义
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
是否使用LADP密码认证,默认No
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
centreon配置检查
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
Centreon数据库检查
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
点击Click here to complete yourinstall完成安装
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
登陆首页界面
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
登陆后界面
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
检查nagios.cfg的配置,configuration -> nagios-> nagios.cfg -> Nagios CFG1
  点击Data标签,检查NDO的配置,主要有以下2项
  Broker Module      /usr/local/nagios/bin/ndomod.oconfig_file=/usr/local/nagios/etc/ndomod.cfg
  Broker ModuleOptions-1
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
检查ndo2db.cfg的配置,configuration -> centreon-> ndo2db.cfg -> Principal
  点击General标签,检查NDO的配置,主要有以下3项
  Socket Type   tcp
  Socket Name/var/run/ndo.sock
  TCP Port5668
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
检查ndomod.cfg的配置,configuration -> centreon-> ndomod.cfg ->Central-mod
  检查NDO的配置,主要有以下3项
  Interface Typetcpsocket
  Output    127.0.0.1
  TCP Port5668
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
nagios配置生成检查,configuration-> nagios -> Generate-> Export
  
http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
配置检查正确后,将Actions项其他三个勾选上生成配置。

  8)、启动相关服务
  # /etc/init.d/nagios start
  #/etc/init.d/ndo2db restart
  #/etc/init.d/centcore start
  #/etc/init.d/centstorage start
  #/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg–d
  
  9)、centreon汉化
  #wgethttp://cacti-nagios.googlecode.com/files/messages.mo
  #mkdir -p/usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
  #cpmessages.mo/usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
  #chownapache:apache -R /usr/local/centreon/www/locale
  http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif
Administration -> admin-> Language选择zh_CN,设置完成后重新登陆
  
  http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif


  三、client端服务安装(与server端完全一样,只是需要修改nrpe的配置)
  1)、安装nagios-plugins
  #cd/usr/local/src/
  #useradd -M-s /sbin/nologin nagios
  #tar zxfnagios-plugins-1.4.16.tar.gz
  #cdnagios-plugins-1.4.16
  #./configure --with-nagios-user=nagios--with-nagios-
  
  group=nagios--with-openssl=/usr/bin/openssl --enable-perl-modules
  #make
  #make install
  #cd ../
  
  2)、安装nrpe
  #tar zxfnrpe-2.13.tar.gz
  #cdnrpe-2.13
  #./configure
  #makeall
  #makeinstall-plugin
  #makeinstall-daemon
  #makeinstall-daemon-config
  # vi/usr/local/nagios/etc/nrpe.cfg
  allowed_hosts=127.0.0.1
  修改为nagiosserver的IP
  allowed_hosts=192.168.128.21
  #/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg–d
  
  接下来就可以通过centreon强大的web界面来配置监控项,下次再说~~~

lxh9090 发表于 2016-5-31 09:06:32

好文章啊!!
页: [1]
查看完整版本: centreon+nagios安装测试(一…