十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
监控系统是运维人员的一个重要工具,熟悉其的构建与应用必不可少。nagios与centreon的搭
创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都网站设计、网站制作、海城网络推广、微信小程序开发、海城网络营销、海城企业策划、海城品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供海城建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com
配是开源软件最佳选择。现在将我的构建与应用过程记录如下。
一.环境预安装
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 |
如果不安装第三方源会导致相关软件包不能安装,进而导致主安装出现相关问题。
3.安装相关软件包
安装apache [root@localhost ~]# yum -y install httpd [root@localhost ~]# yum install MySQL-devel openssl-devel mysql-server 在/etc/my.conf中的[mysqld]加入 innodb_file_per_table=1 否则在web安装第七步时会有提示。 安装php RRDTools 安装perl 安装SNMP
|
二. 主软件包安装
nagios主要监控系统与网络信息,同时监控远程与本地主机及相关服务,还提供信息异常功能
1.安装nagios
添加相关用户及组 [root@localhost ~]# useradd -m nagios 安装nagios [root@localhost monitor]# tar -zxvf nagios-3.5.0.tar.gz |
nagios如果少了其插件,将什么也做不了,其功能主要通过插件来完成的。
2.nagios-pluigns安装
[root@localhost monitor]# tar -zxvf nagios-plugins-1.4.16.tar.gz |
3.ndoutils安装
ndoutils主要将相关数据存储到数据库,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方式展现给用户,通过第三方软件实现对网络,应用程序,主机的监控。
注:如下安装过程只做参考,其不是第一次安装 ,与第一次安装可能有所不同,第一次安装时会更新相关模块。
文本安装
[root@localhost monitor]# tar -zxvf centreon-2.4.2.tar.gz
You will now read Centreon Licence. Do you want to install : Centreon Web Front Do you want to install : Centreon CentCore Do you want to install : Centreon Nagios Plugins Do you want to install : Centreon Snmp Traps process ------------------------------------------------------------------------ Where is your Centreon directory? Do you want me to create this directory ? [/usr/local/centreon] Where is your Centreon log directory Do you want me to create this directory ? [/usr/local/centreon/log] Where is your Centreon etc directory Do you want me to create this directory ? [/usr/local/centreon/etc] Where is your Centreon binaries directory Do you want me to create this directory ? [/usr/local/centreon/bin] Where is your Centreon data informations directory Do you want me to create this directory ? [/usr/local/centreon/data] Where is your Centreon generation_files directory? Where is your Centreon variable library directory? Do you want me to create this directory ? [/usr/local/centreon/var/lib] Where is your CentPlugins Traps binary Where is the RRD perl module installed [RRDs.pm] Where is PEAR [PEAR.php] What is the Centreon group ? [centreon] What is the Centreon user ? [centreon] What is the Monitoring engine user ? What is the Broker user ? (optional) What is the Monitoring engine log directory ? Where is your monitoring plugins (libexec) directory ? ------------------------------------------------------------------------ Where is sudo configuration file What is the Monitoring engine init.d script ? What is the Monitoring engine binary ? What is the Monitoring engine configuration directory ? Where is the configuration directory for broker module ? Where is the init script for broker module daemon ? Do you want me to reconfigure your sudo ? (WARNING) ------------------------------------------------------------------------ Do you want to update Centreon Apache sub configuration file ? Do you want to reload your Apache ? ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------------------------ Where is your Centreon Run Dir directory? Do you want me to create this directory ? [/usr/local/centreon/var/run] Where is your CentStorage binary directory Where is your CentStorage RRD directory Do you want me to install CentStorage init script ? Do you want me to install CentStorage run level ? ------------------------------------------------------------------------ Where is your CentCore binary directory Do you want me to install CentCore run level ? ------------------------------------------------------------------------ Where is your CentPlugins lib directory Do you want me to create this directory ? [/usr/local/centreon/var/lib/centplugins/] ------------------------------------------------------------------------ Where is your SNMP configuration directory Where is your SNMPTT binaries directory |
web安装
(1)centreon的欢迎界面
(2)检查依赖关系
(3)配置nagios信息
(4)配置ndoutils模块
(5)配置admin用户
(6)配置数据库信息
(7)安装
(8)安装完成
5.服务器端nrpe安装
nrpe是nagios组件,能够执行远程主机的本地检测脚本,监控运行状态。
[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 |
服务器端检测错误
[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 |
三.后续登录错误
1.错误信息
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'; mysql> grant all on centreon_storage.* to centreon@localhost identified by '123456'; mysql> flush privileges; |
成功页面如下
四.检查重新生成配置文件
(1)检查main.cfg的配置
(2)检查ndo2db.cfg的配置
(3)检查ndomod.cfg的配置
(4)生成nagios配置文件
web页面重启完成后,查看nagios相关日志
[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的服务器端已经配置完成,对于其被监控主机上也安装nagios-plugins和nrpe软件包,这里就不再重复,centreon的应用配置及汉化后续再出。