本例在CentOS 6.5 64位系统安装
Centos 6.4-64bit
说明:nagios所支持折系统较多,本手册接下来的所有操作都是在centos上,所以会要求centos系统
按系统/var分区要大一点,将会是大部分数据存放的路径
rpm-ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum update
yum upgrade
chkconfig --level 35 iptables off
vi /etc/selinux/config
将SELINUX=enforcing 修改为:SELINUX=disabled
Setenforce 0
yum install httpd
usermod -U apache
yum install gd fontconfig-devel libjpeg-devellibpng-devel gd-devel perl-GD
yum install openssl-devel perl-DBD-MySQL mysql-servermysql-devel
yum install php php-mysql php-gd php-ldap php-xmlphp-mbstring
yum install perl-Config-IniFiles perl-DBI
yum install rrdtool perl-rrdtool
yum install perl-Crypt-DES perl-Digest-SHA1perl-Digest-HMAC net-snmp-utils
yum install perl-Socket6 perl-IO-Socket-INET6 net-snmp
yum install php-snmp dmidecode lm_sensorsperl-Net-SNMP net-snmp-perl
yum groupinstall "Development Tools"
yum install fping glib2-devel
yum install php-pear
pear channel-update pear.php.net
pear upgrade-all
1.wgethttp://jaist.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.4/nagios-4.0.4.tar.gz
2.wgethttp://jaist.dl.sourceforge.net/project/nagios/ndoutils-2.x/ndoutils-2.0.0/ndoutils-2.0.0.tar.gz
3.wgethttp://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
4.wgethttp://download.centreon.com/centreon/centreon-2.5.0.tar.gz
5.wgethttp://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
6.centreon-clapi-1.5.2 下载地址http://download.centreon.com/index.php?id=4296
[root@jk soft]# useradd nagios
[root@jk soft]# groupadd nagcmd
[root@jk soft]# usermod -G nagios,nagcmd nagios
[root@jk soft]# tar xvzf nagios-4.0.4.tar.gz
[root@jk soft]# cd nagios-4.0.4
[root@jk nagios-4.0.4]# ./configure--prefix=/usr/local/nagios --with-command-group=nagcmd --enable-nanosleep--enable-event-broker --enable-embedded-perl
[root@jk nagios-4.0.4]# make all&&makeinstall&&make install-init&&make install-commandmode&&makeinstall-config&&make install-webconf
[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
1.[root@jk nagios-4.0.4]# cd ..
2.[root@jk soft]# tar xvzf nagios-plugins-2.0.tar.gz
3.[root@jk nagios-plugins-2.0]# ./configure--with-nagios-user=nagios --with-nagios-group=nagios--with-openssl=/usr/bin/openssl --enable-perl-modules
4.[root@jk nagios-plugins-2.0]# make&&makeinstall
如果出现类似如下错误:
Working in: /soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98
Using Makefile.PL
Can't locate ExtUtils/MakeMaker.pm in @INC (@INCcontains: /soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98/blib/lib/soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98/blib/arch /usr/local/lib64/perl5/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) atMakefile.PL line 6.
BEGIN failed--compilation aborted at Makefile.PL line6.
.make[3]: Entering directory `/soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98'
make[3]: *** No targets specified and no makefilefound. Stop.
09.make[3]: Leaving directory`/soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98'
Can't run make. Please
rm -rf/soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98
to remake from this point) at../tools/build_perl_modules line 235.
make[2]: *** [all-local] Error 2
make[2]: Leaving directory`/soft/nagios-plugins-2.0/perlmods'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/soft/nagios-plugins-2.0'
make: *** [all] Error 2
这个是缺少Perl模块导致 安装
1.yum install perl-ExtUtils-MakeMaker
然后再次make&&make install
[root@jk nagios-plugins-2.0]# cd ..
[root@jk soft]# tar xvzf nrpe-2.15.tar.gz
[root@jk soft]# cd nrpe-2.15
[root@jk nrpe-2.15]# ./configure
[root@jk nrpe-2.15]# make all&&makeinstall-plugin&&make install-daemon&&make install-daemon-config
[root@jk nrpe-2.15]# cd ..
[root@jk soft]# tar xvzf ndoutils-2.0.0.tar.gz
[root@jk soft]# cd ndoutils-2.0.0
[root@jk ndoutils-2.0.0]# ./configure --prefix=/usr/local/nagios/--enable-mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
[root@jk ndoutils-2.0.0]# make&&make install
[root@jk ndoutils-2.0.0]# cp./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
[root@jk ndoutils-2.0.0]# cp ./config/ndomod.cfg-sample/usr/local/nagios/etc/ndomod.cfg
[root@jk ndoutils-2.0.0]# cp daemon-init/etc/init.d/ndo2db
修改启动脚本killproc_ndo2db()和 stop)的内容 修改成以下内容:
[root@jk ndoutils-2.0.0]# vi /etc/init.d/ndo2db
killproc_ndo2db () { kill`pidof ndo2db |cut -f1` > /dev/null 2>&1; kill`pidof ndo2db |cut -f1` > /dev/null 2>&1; } stop) echo "Stopping $servicename..." killproc_ndo2db ;;
[root@jk ndoutils-2.0.0]# chmod +x/etc/init.d/ndo2db
[root@jk ndoutils-2.0.0]# chkconfig --add ndo2db
[root@jk ndoutils-2.0.0]# chkconfig --level 345ndo2db on
[root@jk ndoutils-2.0.0]# cd ../
[root@jk soft]# tar xvzf centreon-2.5.0.tar.gz
[root@jk soft]# cd centreon-2.5.0
[root@jk centreon-2.5.0]# ./install.sh -i
第一步:检查先决条件
############################################################################### # # # Centreon (www.centreon.com) # # Thanks for using Centreon # # # # v2.5.0 # # # # [email protected] # # # # Make sure you have installed and configured # # sudo - sed - php - apache - rrdtool - mysql # # # ############################################################################### ------------------------------------------------------------------------ Checkingall needed binaries ------------------------------------------------------------------------ rm OK cp OK mv OK /bin/chmod OK /bin/chown OK echo OK more OK mkdir OK find OK /bin/grep OK /bin/cat OK
/bin/sed OK
现在centreon许可证(gpl2)显示。如果你不接受它的安装程序将终止。
This GeneralPublic License does not permit incorporating your program into proprietaryprograms. If your program is asubroutine library, you may consider it moreuseful to permit linking proprietary applications with the library. If this is what you want to do, use the GNULibrary General Public Licenseinstead of this License. Do you accept GPLlicense ? [y/n], default to[n]: > y
现在有些问题对于即将安装的模块:centreon Web界面,centcore(分配模块),centreon插件和centreon接口处理程序。
------------------------------------------------------------------------ Pleasechoose what do you want to install ------------------------------------------------------------------------ Do you want to install Centreon Web Front [y/n], default to [n]: > y Do you want to install Centreon CentCore [y/n], default to [n]: > y Do you want to install Centreon Nagios Plugins [y/n], default to [n]: > y Do you want to install Centreon Snmp Traps process [y/n], default to [n]: > y Now the installation of the different modules begins,starting with Centreon Web, the centreon interface. ------------------------------------------------------------------------ StartCentWeb Installation ------------------------------------------------------------------------ Where is your Centreon directory? default to [/usr/local/centreon] > Where should centreon be installed? <Enter> acceptsthe shown default value. You can specify another path. If the directory doesn'texist you are asked if it should be created: Do you want me to create this directory ?[/usr/local/centreon] [y/n], default to [n]: > y Path /usr/local/centreon OK Here you should specify where to put the centreonjournals/logs. Where is yourCentreon log directory default to[/usr/local/centreon/log/] > Do you want me tocreate this directory ? [/usr/local/centreon/log/] [y/n], default to[n]: > y Path/usr/local/centreon/log/ OK very important : the location of centreon config file.\\ATTENTION: changing the path may result in problems... Where is your Centreon etc directory default to [/etc/centreon] > Do you want me to create this directory ? [/etc/centreon] [y/n], default to [n]: > y Path /etc/centreon OK Where is your Centreon generation_files directory? default to [/usr/local/centreon/] > Path /usr/local/centreon/ OK Where is your Centreon variable library directory? default to [/var/lib/centreon] > Do you want me to create this directory ?[/var/lib/centreon] [y/n], default to [n]: > y Path /var/lib/centreon Where is your CentPlugins Traps binary default to [/usr/local/centreon/bin] > Do you want me to create this directory ?[/usr/local/centreon/bin] [y/n], default to [n]: > y Path /usr/local/centreon/bin OK Where is the RRD perl module installed [RRDs.pm] default to [/usr/lib/perl5/RRDs.pm] > Path /usr/lib/perl5 OK /usr/bin/rrdtool OK /usr/bin/mail OK Where is PEAR [PEAR.php] default to [/usr/share/php/PEAR.php] > Path /usr/share/php OK Where is installed Nagios ? default to [/usr/local/nagios] > Path /usr/local/nagios OK Where is your nagios config directory default to [/usr/local/nagios/etc] > Path /usr/local/nagios/etc OK Where is your Nagios var directory ? default to [/usr/local/nagios/var] > Path /usr/local/nagios/var OK Where is your Nagios plugins (libexec) directory ? default to [/usr/local/nagios/libexec] > Path /usr/local/nagios/libexec OK /usr/local/nagios/bin//nagios OK Where is your Nagios image directory ? default to [/usr/local/nagios/share/images/logos] > Path /usr/local/nagios/share/images/logos OK /usr/local/nagios/bin//nagiostats OK p1_file : /usr/local/nagios/bin/p1.pl OK /usr/bin/php OK /usr/bin/perl OK Finding Apache group : apache Finding Apache user : apache Finding Nagios user : nagios Finding Nagios group : nagios /usr/local/nagios/bin//ndomod.o OK ATTENTION: the name of user and group of the web serverdepends from the used distribution! ------------------------------------------------------------------------ Configure Sudo ------------------------------------------------------------------------ Where is sudo configuration file default to [/etc/sudoers] > /etc/sudoers OK Nagios init script OK Your sudo is not configured Do you want me to configure your sudo ? (WARNING) [y/n], default to [n]: > y Configuring Sudo OK Setting up the centreon Aliases etc ------------------------------------------------------------------------ ConfigureApache server ------------------------------------------------------------------------ Do you want to add Centreon Apache sub configuration file? [y/n], default to [n]: > y Create '/etc/apache2/conf.d/centreon.conf' OK Configuring Apache OK Do you want to reload your Apache ? [y/n], default to [n]: > n Preparing Centreon temporary files Change right on /usr/local/centreon/log OK Change right on /etc/centreon OK Change right on /usr/local/nagios/share/images/logos OK Install nagios documentation OK Change macros for insertBaseConf.sql OK Change macros for php files Change macros for php files OK Change right on /usr/local/nagios/etc OK Copy CentWeb in system directory Install CentWeb (web front of centreon) OK Install libraries OK Copying libinstall OK Change macros for centreon.cron OK Install Centreon cron.d file OK Change macros for archiveDayLog OK Change macros for centAcl.php OK Install cron directory OK PEAR libraries: a set of libraries is still missing butthey will be installed or updated as nessecary (if you have a connection to theinternet). Otherwise you have to install them manually :-(. ------------------------------------------------------------------------ Pear Modules ------------------------------------------------------------------------ Check PEAR modules PEAR 1.4.9 1.6.1 OK DB 1.7.6 NOK DB_DataObject 1.8.4 NOK DB_DataObject_FormBuilder 1.0.0RC4 NOK MDB2 2.0.0 NOK Date 1.4.6 NOK HTML_Common 1.2.2 NOK HTML_QuickForm 3.2.5 NOK HTML_QuickForm_advmultiselect 1.1.0 NOK HTML_Table 1.6.1 NOK Archive_Tar 1.1 1.3.2 OK Auth_SASL 1.0.1 NOK Console_Getopt 1.2 1.2.3 OK Net_SMTP 1.2.8 NOK Net_Socket 1.0.1 NOK Net_Traceroute 0.21 NOK Net_Ping 2.4.1 NOK Validate 0.6.2 NOK XML_RPC 1.4.5 NOK SOAP 0.10.1 NOK Log 1.9.11 NOK After displaying the current versions you may get therequest to update some libraries. Do you want me to install/upgrade your PEAR modules [y/n], default to [y]: Upgrading PEAR modules Installing PEAR modules DB 1.7.6 1.7.13 OK DB_DataObject 1.8.4 1.8.12 OK DB_DataObject_FormBuilder 1.0.0RC4 1.0.0 OK MDB2 2.0.0 2.4.1 OK HTML_QuickForm_advmultiselect 1.1.0 1.5.1 OK HTML_Table 1.6.1 1.8.2 OK Auth_SASL 1.0.1 1.0.3 OK Net_SMTP 1.2.8 1.3.3 OK Net_Traceroute 0.21 0.21.1 OK Net_Ping 2.4.1 2.4.4 OK Validate 0.6.2 0.8.2 OK XML_RPC 1.4.5 1.5.2 OK SOAP 0.10.1 0.12.0 OK Log 1.9.11 1.11.5 OK Check PEAR modules PEAR 1.4.9 1.6.1 OK DB 1.7.6 1.7.13 OK DB_DataObject 1.8.4 1.8.12 OK DB_DataObject_FormBuilder 1.0.0RC4 1.0.0 OK MDB2 2.0.0 2.4.1 OK Date 1.4.6 1.4.7 OK HTML_Common 1.2.2 1.2.5 OK HTML_QuickForm 3.2.5 3.2.11 OK HTML_QuickForm_advmultiselect 1.1.0 1.5.1 OK HTML_Table 1.6.1 1.8.2 OK Archive_Tar 1.1 1.3.2 OK Auth_SASL 1.0.1 1.0.3 OK Console_Getopt 1.2 1.2.3 OK Net_SMTP 1.2.8 1.3.3 OK Net_Socket 1.0.1 1.0.9 OK Net_Traceroute 0.21 0.21.1 OK Net_Ping 2.4.1 2.4.4 OK Validate 0.6.2 0.8.2 OK XML_RPC 1.4.5 1.5.2 OK SOAP 0.10.1 0.12.0 OK Log 1.9.11 1.11.5 OK All PEAR modules OK The script will continue. ------------------------------------------------------------------------ Centreon Post Install ------------------------------------------------------------------------ Create/usr/local/centreon/www/install/install.conf.php OK Create /etc/centreon/instCentWeb.conf OK Now CentStorage will be installed, also called ODS (OreonData Storage). At the moment this module permits archiving on the basis of RRDand MySQL. Additionally CentStorage enables you to create graphs for monitoringthe different metrics. ------------------------------------------------------------------------ StartCentStorage Installation ------------------------------------------------------------------------ Where is your Centreon Run Dir directory? default to [/var/run/centreon] > Do you want me to create this directory ?[/var/run/centreon] [y/n], default to [n]: > y Path /var/run/centreon OK Where is your CentStorage binary directory default to [/usr/local/centreon/bin] > Path /usr/local/centreon/bin OK Where is your CentStorage RRD directory default to [/var/lib/centreon] > Path /var/lib/centreon OK Attention: the centreon lib directory should be placed ona continously available partition to avoid problems. The directory contains theRRDTools. Consider to place the MySQl data on a reasonably dimensioned disk.The logs and performance data also need a lot of space. Path /var/lib/centreon OK Finding Nagios group : nagios Finding Nagios user : nagios Preparing Centreon temporary files /tmp/centreon-setup exists, it will be moved... install www/install/createTablesCentstorage.sql OK Creating Centreon Directory'/var/lib/centreon/status' OK Creating Centreon Directory'/var/lib/centreon/metrics' OK Change macros for centstorage binary OK Install CentStorage binary OK Install library for centstorage OK Change right : /var/run/centreon OK Change macros for centstorage init script OK Do you want me to install CentStorage init script ? [y/n], default to [n]: > y CentStorage init script installed OK Do you want me to install CentStorage run level ? [y/n], default to [n]: > y Adding systemstartup for /etc/init.d/centstorage ... /etc/rc0.d/K30centstorage -> ../init.d/centstorage /etc/rc1.d/K30centstorage -> ../init.d/centstorage /etc/rc6.d/K30centstorage -> ../init.d/centstorage /etc/rc2.d/S40centstorage -> ../init.d/centstorage /etc/rc3.d/S40centstorage -> ../init.d/centstorage /etc/rc4.d/S40centstorage -> ../init.d/centstorage /etc/rc5.d/S40centstorage -> ../init.d/centstorage Change macros for logAnalyser OK Install logAnalyser OK Change macros for nagiosPerfTrace OK Install nagiosPerfTrace OK Change macros for purgeLogs OK Install purgeLogs OK Change macros for purgeCentstorage OK Install purgeCentstorage OK Change macros for centreonPurge.sh OK Install centreonPurge.sh OK Change macros for centstorage.cron OK Install CentStorage cron OK Create /etc/centreon/instCentStorage.conf OK CentStorage is installed now. ------------------------------------------------------------------------ StartCentCore Installation ------------------------------------------------------------------------ Where is your CentCore binary directory default to [/usr/local/centreon/bin] > Path /usr/local/centreon/bin OK /usr/bin/ssh OK /usr/bin/scp OK Finding Nagios group : nagios Finding Nagios user : nagios Preparing Centreon temporary files /tmp/centreon-setup exists, it will be moved... Change CentCore Macro OK Copy CentCore in binary directory OK Change right : /var/run/centreon OK Change right : /var/lib/centreon OK Replace CentCore init script Macro OK Do you want me to install CentCore init script ? [y/n], default to [n]: > y CentCore init script installed OK Do you want me to install CentCore run level ? [y/n], default to [n]: > y Adding systemstartup for /etc/init.d/centcore ... /etc/rc0.d/K30centcore -> ../init.d/centcore /etc/rc1.d/K30centcore -> ../init.d/centcore /etc/rc6.d/K30centcore-> ../init.d/centcore /etc/rc2.d/S40centcore -> ../init.d/centcore /etc/rc3.d/S40centcore -> ../init.d/centcore /etc/rc4.d/S40centcore -> ../init.d/centcore /etc/rc5.d/S40centcore -> ../init.d/centcore Create /etc/centreon/instCentCore.conf OK Please answer some questions regarding the installationof the centreon plugins. ------------------------------------------------------------------------ StartCentPlugins Installation ------------------------------------------------------------------------ Where is your CentPlugins lib directory default to [/var/lib/centreon/centplugins] > Do you want me to create this directory ?[/var/lib/centreon/centplugins] [y/n], default to [n]: > y Path /var/lib/centreon/centplugins OK Finding Nagios user : nagios Finding Nagios group : nagios Preparing Centreon temporary files /tmp/centreon-setup exists, it will be moved... Change macros for CentPlugins OK Installing the plugins OK Change right on centreon.conf OK CentPlugins is installed ------------------------------------------------------------------------ StartCentPlugins Traps Installation ------------------------------------------------------------------------ Where is your SNMP configuration directory default to [/etc/snmp] > /etc/snmp OK Where is your SNMPTT binaries directory default to [/usr/local/centreon/bin/] > /usr/local/centreon/bin/ OK Finding Nagios group : nagios Finding Apache user : apache Preparing Centreon temporary files /tmp/centreon-setup exists, it will be moved... Change macros for CentPluginsTraps OK Installing the plugins Trap binaries OK Backup all your snmp files OK Change macros for snmptrapd.conf OK Change macros for snmptt.ini OK Install : snmptrapd.conf OK Install : snmp.conf OK Install : snmptt.ini OK Install : snmptt OK Install : snmpttconvertmib OK Create /etc/centreon/instCentPlugins.conf OK ############################################################################### # # # Go to the URL : http://your-server/centreon/ # # to finish thesetup # # # # Report bugs athttp://forge.centreon.com # # # # Thanks for usingCentreon. # # ----------------------- # # Contact :[email protected] # # http://www.centreon.com # # # ###############################################################################
[root@jk centreon-2.5.0]# /etc/init.d/httpd start
[root@jk centreon-2.5.0]# /etc/init.d/mysqld start
[root@jk centreon-2.5.0]# mysqladmin -u root -ppassword 'mysqlpasswd'
[root@jk centreon-2.5.0]# /etc/init.d/ndo2db start
配置并启动nrpe
修改/usr/local/nagios/etc/nrpe.cfg
#allowed_hosts=127.0.0.1 这句修改为
allowed_hosts=127.0.0.1,192.168.105.35
command[check_hda1]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /dev/hda1这句修改如下
command[check_disk]=/usr/local/nagios/libexec/check_disk-w 20% -c 10% -p /
启动
/usr/local/nagios/bin/nrpe -c/usr/local/nagios/etc/nrpe.cfg -d
把上面这句加到/etc/rc.d/rc.loal
http://x.x.x.x/centreon 打开安装程序
如图:
填写正确的路径
填写管理员密码和邮箱
填写数据库用户名和密码
遇到下面这个错误
在/etc/my.cnf 的MYSQLD段添加下面一句
innodb_file_per_table=1
然后重新启动MYSQL
service mysqld restart
Configuration->Monitoring Engines->Generate 勾选所有,然后点击Export
9. centreon汉化
[root@centreon ~]#wgethttp://cacti-nagios.googlecode.com/files/messages.mo
[root@centreon ~]#mkdir -p/usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
[root@centreon ~]#cp messages.mo/usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
[root@centreon ~]#chown apache:apache -R/usr/local/centreon/www/locale