本文介绍完整的nagios和centreon安装过程。
安装环境:
CentOS5.6,X64 updated。
Monitor Engine:Nagios
Broker module:NDoutils
假设:
已安装并启动mysql
路径为:/usr/local/mysql/
sock路径:/var/lib/mysql/mysql.sock
步骤参考英文原文:
1、下载安装包
#下载nagios、nagios-plugin、nrpe、ndoutils以及ndoutils的一个patch
cd /data/tool
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.1.tar.gzwget --no-check-certificate https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gzwget http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gzwget http://nchc.dl.sourceforge.net/project/nagios/ndoutils-1.x/ndoutils-1.5.2/ndoutils-1.5.2.tar.gzwget http://svn.centreon.com/trunk/ndoutils-patch/ndoutils1.5.2_light.patch#在 检查安装centreon所需要的软件包
#下载 centreon 2.4.0
wget http://download.centreon.com/index.php?id=4264#安装一些必要的package
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp
2、开始安装nagios
#建立用户和组
chattr -i /etc/passwd /etc/shadow /etc/group /etc/gshadowuseradd nagiosgroupadd nagcmdusermod -a -G nagcmd nagiosusermod -a -G nagcmd apache#安装 nagios-core
tar -zxvf nagios-3.5.1.tar.gzcd nagios./configure --prefix=/usr/local/nagios --with-command-group=nagcmd \--enable-event-broker --enable-embedded-perl --with-perlcachemake allmake installmake install-initmake install-configmake install-commandmodemake install-webconfcp -R contrib/eventhandlers/ /usr/local/nagios/libexec/chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
#启动 nagios apache
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg/etc/init.d/nagios start/etc/init.d/httpd start#创建nagios用户用于登录
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin#安装 nagios-plugins
tar -zxvf nagios-plugins-1.5.tar.gzcd ../nagios-plugins-1.5./configure --with-nagios-user=nagios \--with-nagios-group=nagios \--prefix=/usr/local/nagios \--enable-redhat-pthread-workaround --with-ipv6=no \--enable-perl-modules \--with-mysql=/usr/local/mysqlmake && make install#安装nrpe
tar -zxvf nrpe-2.15.tar.gz./configure --prefix=/usr/local/nagiosmake allmake install-pluginmake install-daemonmake install-daemon-configmake install-xinetd
安装xinetd以便管理
yum install xinetd -ysed -i 's/127.0.0.1/127.0.0.1 183.61.70.34/' /etc/xinetd.d/nrpesed -i '578 i\nrpe 5666/tcp # NRPE' /etc/servicesservice xinetd restart
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_userssed -i 's/allowed_hosts=127.0.0.1/allowed_hosts=127.0.0.1,/' /usr/local/nagios/etc/nrpe.cfg
3、安装 ndoutils
tar -zxvf ndoutils-1.5.2.tar.gzcd ndoutils-1.5.2patch -p1 -N < ../ndoutils1.5.2_light.patch./configure --prefix=/usr/local/nagios/ --enable-mysql --with-mysql=/usr/local/mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios默认的源文件 make 会报错 修改如下
sed -i -e 's/#include/#include <\/usr\/local\/mysql\/include\/mysql.h>/' include/config.hsed -i -e 's/#include /#include <\/usr\/local\/mysql\/include\/errmsg.h>/' include/config.hmakemake install
cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfgcp ./config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg#编辑/usr/local/nagios/etc/nagios.cfg 在broker_module处添加
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
#安装启动文件
chmod +x daemon-initcp daemon-init /etc/init.d/ndo2db
#创建数据库用户
mysql -p>>create database nagios;GRANT ALL PRIVILEGES ON nagios.* TO 'nagios'@'localhost' IDENTIFIED BY 'nagios';>>FLUSH PRIVILEGES;
#安装数据库
cd db/./installdb -u nagios -p nagios -h localhost -d nagios
4、安装 centreon
usermod -a -G apache centreonusermod -a -G nagios centreonwget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpmwget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txtrpm --import RPM-GPG-KEY.dag.txtrpm -ivh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpmyum clean allyum updateyum upgradeyum install httpd gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD \ openssl-devel perl-DBD-MySQL mysql-server mysql-devel php php-mysql php-gd php-ldap php-xml php-mbstring \ perl-Config-IniFiles perl-DBI perl-DBD-MySQL rrdtool perl-rrdtool perl-Crypt-DES perl-Digest-SHA1 \ perl-Digest-HMAC net-snmp-utils perl-Socket6 perl-IO-Socket-INET6 net-snmp net-snmp-libs php-snmp \ dmidecode lm_sensors perl-Net-SNMP net-snmp-perl fping cpp gcc gcc-c++ libstdc++ glib2-devel \ php-pear
usermod -U apachepear channel-update pear.php.netpeardev upgrade-allpear upgrade-all
报错处理:[PHP Fatal error: Allowed memory size of 8388608 bytes exhausted]
echo 'memory_limit = 256M' >>/etc/php.ini
#开始安装centreon
./install.sh -i
#经过一系列回车(保持默认配置)以及需要填写的路径完成命令行下的centreon安装。
#此处不一一贴出
#需要注意的两个路径RRDs.pm、PEAR.php 可使用find 找到准确路径
/usr/local/rrdtool/lib/perl/5.8.8/x86_64-linux-thread-multi/RRDs.pm/usr/share/pear/PEAR.php
#配置centreon数据库用户
GRANT ALL PRIVILEGES ON `centreon`.* TO 'centreon'@'localhost' identified by 'centreon';GRANT ALL PRIVILEGES ON `centreon_storage`.* TO 'centreon'@'localhost' identified by 'centreon';GRANT ALL PRIVILEGES ON `centreon_status`.* TO 'centreon'@'localhost' identified by 'centreon';FLUSH PRIVILEGES;
#登录web界面进行下一步安装:
#检查php拓展
#配置Nagios相关路径
#配置NDoutils路径
#管理员账户密码
#数据库连接信息
#安装完成可登录
以上为centreon安装完整步骤,坑稍微有点多。
特别是centreon命令行模式安装时每个路径、文件名都不要写错。