安裝Nagios4.0.8 && Centreon2.6.0

urgel_babay發表於2016-05-11
安裝Nagios4.0.8 && Centreon2.6.0



作業系統CentOS6.4 64


一. 安裝CentOS6.4作業系統,最小化安裝


注意事項:
注意配置閘道器,不然網路連線會有問題
[root@nagios etc]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=nagios
GATEWAY=192.168.9.1


同步時間:
yum install crontab*
yum install ntp*


關閉防火牆
service iptables stop
chkconfig iptables off




然後重啟系統
reboot


 


二。安裝APACHE 也可根據情況安裝NGINX


yum install httpd
usermod -U apache
 


安裝GD庫


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


安裝MySQL資料庫


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


安裝PHP和擴充套件


yum install php php-mysql php-gd php-ldap php-xml php-mbstring
 


安裝Perl擴充套件


yum install perl-Config-IniFiles perl-DBI
 


安裝RRDtool


yum install rrdtool perl-rrdtool
 


安裝SNMP


yum install perl-Crypt-DES perl-Digest-SHA1 perl-Digest-HMAC net-snmp-utils
yum install perl-Socket6 perl-IO-Socket-INET6 net-snmp
yum install php-snmp dmidecode lm_sensors perl-Net-SNMP net-snmp-perl


安裝開發庫


yum groupinstall "Development Tools"
 


其他庫


yum install fping glib2-devel
 


安裝PEAR


yum install php-pear
pear channel-update pear.php.net
pear upgrade-all
 


下載所需用的的軟體


wget
wget
wget
wget
wget


centreon-clapi-1.5.2 下載地址


安裝Nagios


[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.8.tar.gz
[root@jk soft]# cd nagios-4.0.8
[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&&make install&&make install-init&&make install-commandmode&&make install-config&&make install-webconf




安裝Nagios外掛


[root@jk nagios-4.0.4]# cd ..
[root@jk soft]# tar xvzf nagios-plugins-2.0.tar.gz
[root@jk nagios-plugins-2.0]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules
[root@jk nagios-plugins-2.0]# make&&make install


如果出現類似如下錯誤:


Working in: /soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98
Using Makefile.PL
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /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 .) at Makefile.PL line 6.
BEGIN failed--compilation aborted at Makefile.PL line 6.
make[3]: Entering directory `/soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98'
make[3]: *** No targets specified and no makefile found.  Stop.
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模組導致 安裝


yum install perl-ExtUtils-MakeMaker


然後再次make&&make install






安裝Nrpe


[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&&make install-plugin&&make install-daemon&&make install-daemon-config






安裝Ndoutils


[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 -d " "` >/dev/null 2>&1
    kill`pidof ndo2db |cut -f1 -d " "` >/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 345 ndo2db on
 


安裝Centreon


[root@jk ndoutils-2.0.0]# cd ../
[root@jk soft]# tar xvzf centreon-2.6.0.tar.gz
[root@jk soft]# cd centreon-2.6.0
[root@jk centreon-2.5.0]# ./install.sh -i


------------------------------------------------------------------------
Checking all 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
You will now read Centreon Licence.
Press enter to continue.
安裝回車和Q鍵
然後按Y
Do you accept GPL license ?
[y/n], default to [n]:
> y
------------------------------------------------------------------------
Please choose what 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
------------------------------------------------------------------------
Start CentWeb Installation
------------------------------------------------------------------------
Where is your Centreon directory?
default to [/usr/local/centreon]
>
Do you want me to create this directory ? [/usr/local/centreon]
[y/n], default to [n]:
> y
Path /usr/local/centreon                                   OK
Where is your Centreon log directory
default to [/usr/local/centreon/log]
>
Do you want me to create this directory ? [/usr/local/centreon/log]
[y/n], default to [n]:
> y
Path /usr/local/centreon/log                               OK
Where is your Centreon etc directory
default to [/etc/centreon]
> /usr/local/centreon/etc/
Do you want me to create this directory ? [/usr/local/centreon/etc/]
[y/n], default to [n]:
> y
Path /usr/local/centreon/etc/                                         OK
Where is your Centreon binaries directory
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 your Centreon data informations directory
default to [/usr/local/centreon/data]
>
Do you want me to create this directory ? [/usr/local/centreon/data]
[y/n], default to [n]:
> y
Path /usr/local/centreon/data                              OK
Where is your Centreon variable library directory?
default to [/var/lib/centreon]
>/usr/local/centreon/var/lib/
Do you want me to create this directory ? [/usr/local/centreon/var/lib/]
[y/n], default to [n]:
> y
Path /var/lib/centreon                                     OK
/usr/bin/rrdtool                                           OK
/bin/mail                                                  OK
/usr/bin/php                                               OK
Where is PEAR [PEAR.php]
default to [/usr/share/php/PEAR.php]
> /usr/share/pear/PEAR.php
Path /usr/share/pear                                       OK
/usr/bin/perl                                              OK
Finding Apache user :                                      apache
Finding Apache group :                                     apache
What is the Centreon group ? [centreon]
default to [centreon]
>
Do you want me to create this group ? [centreon]
[y/n], default to [n]:
> y
What is the Centreon user ? [centreon]
default to [centreon]
>
Do you want me to create this user ? [centreon]
[y/n], default to [n]:
> y
What is the Monitoring engine user ?
> nagios
What is the Broker user ? (optional)
> nagios
What is the Monitoring engine log directory ?
> /usr/local/nagios/var/
Where is your monitoring plugins (libexec) directory ?
default to [/usr/lib/nagios/plugins]
> /usr/local/nagios/libexec
Path /usr/local/nagios/libexec                             OK
Add group centreon to user apache                          OK
Add group centreon to user nagios                          OK
Add group nagios to user apache                            OK
Add group nagios to user centreon                          OK
------------------------------------------------------------------------
Configure Sudo
------------------------------------------------------------------------
Where is sudo configuration file
default to [/etc/sudoers]
>
/etc/sudoers                                               OK
What is the Monitoring engine init.d script ?
> /etc/init.d/nagios
What is the Monitoring engine binary ?
> /usr/local/nagios/bin/nagios
What is the Monitoring engine configuration directory ?
> /usr/local/nagios/etc
Where is the configuration directory for broker module ?
> /usr/local/nagios/etc
Where is the init script for broker module daemon ?
> /etc/init.d/ndo2db
Your sudo is not configured
Do you want me to configure your sudo ? (WARNING)
[y/n], default to [n]:
> y
Configuring Sudo                                           OK
Configure Apache server
------------------------------------------------------------------------
Do you want to add Centreon Apache sub configuration file ?
[y/n], default to [n]:
> y
Create '/etc/httpd/conf.d/centreon.conf'                   OK
Configuring Apache                                         OK
Do you want to reload your Apache ?
[y/n], default to [n]:
> y
Reloading Apache service                                   FAIL
Preparing Centreon temporary files
Change right on /usr/local/centreon/log                    OK
Change right on /etc/centreon                              OK
Change macros for insertBaseConf.sql                       OK
Change macros for sql update files                         OK
Change macros for php files                                OK
Change macros for perl binary                              OK
Change right on /usr/local/nagios/etc                      OK
Add group nagios to user apache                            OK
Add group nagios to user nagios                            OK
Add group centreon to user nagios                          OK
Copy CentWeb in system directory
Install CentWeb (web front of centreon)                    OK
Change right for install directory
Change right for install directory                         OK
Install libraries                                          OK
Write right to Smarty Cache                                OK
Copying libinstall                                         OK
Change macros for centreon.cron                            OK
Install Centreon cron.d file                               OK
Change macros for centAcl.php                              OK
Change macros for downtimeManager.php                      OK
Install cron directory                                     OK
Change right for eventReportBuilder                        OK
Change right for dashboardBuilder                          OK
Change macros for centreon.logrotate                       OK
Install Centreon logrotate.d file                          OK
Prepare centFillTrapDB                                     OK
Install centFillTrapDB                                     OK
Prepare centreon_trap_send                                 OK
Install centreon_trap_send                                 OK
Prepare centreon_check_perfdata                            OK
Install centreon_check_perfdata                            OK
Prepare centreonSyncPlugins                                OK
Install centreonSyncPlugins                                OK
Prepare centreonSyncArchives                               OK
Install centreonSyncArchives                               OK
Install generateSqlLite                                    OK
Install changeRrdDsName.pl                                 OK
Prepare export-mysql-indexes                               OK
Install export-mysql-indexes                               OK
Prepare import-mysql-indexes                               OK
Install import-mysql-indexes                               OK
Centreon Web Perl lib installed                            OK
------------------------------------------------------------------------
Pear Modules
------------------------------------------------------------------------
Check PEAR modules
PEAR                            1.4.9       1.9.4          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.11         OK
Auth_SASL                       1.0.1                      NOK
Console_Getopt                  1.2         1.3.1          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       1.5.5          OK
SOAP                            0.10.1                     NOK
Log                             1.9.11                     NOK
Archive_Zip                     0.1.2                      NOK
Do you want me to install/upgrade your PEAR modules
[y/n], default to [y]:
> y
Upgrading PEAR modules
Installing PEAR modules
DB_DataObject_FormBuilder       1.0.0RC4    1.0.2          OK
Check PEAR modules
PEAR                            1.4.9       1.9.4          OK
DB                              1.7.6       1.7.14         OK
DB_DataObject                   1.8.4       1.11.2         OK
DB_DataObject_FormBuilder       1.0.0RC4    1.0.2          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.13         OK
HTML_QuickForm_advmultiselect   1.1.0       1.5.1          OK
HTML_Table                      1.6.1       1.8.3          OK
Archive_Tar                     1.1         1.3.11         OK
Auth_SASL                       1.0.1       1.0.6          OK
Console_Getopt                  1.2         1.3.1          OK
Net_SMTP                        1.2.8       1.6.2          OK
Net_Socket                      1.0.1       1.0.14         OK
Net_Traceroute                  0.21        0.21.3         OK
Net_Ping                        2.4.1       2.4.5          OK
Validate                        0.6.2       0.8.5          OK
XML_RPC                         1.4.5       1.5.5          OK
SOAP                            0.10.1      0.13.0         OK
Log                             1.9.11      1.12.7         OK
Archive_Zip                     0.1.2       0.1.2          OK
All PEAR modules                                           OK
------------------------------------------------------------------------
Centreon Post Install
------------------------------------------------------------------------
Create /usr/local/centreon/www/install/install.conf.php    OK
Create /etc/centreon/instCentWeb.conf                      OK
------------------------------------------------------------------------
Start CentStorage Installation
------------------------------------------------------------------------
Where is your Centreon Run Dir directory?
default to [/usr/local/centreon/v/var/run/]
>
Do you want me to create this directory ? [/usr/local/centreon/v/var/run/]
[y/n], default to [n]:
> y
Path /usr/local/centreon/var/run/                                     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
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
Install CentStorage binary                                 OK
Change right : /var/run/centreon                           OK
Change macros for centstorage init script                  OK
Replace CentStorage sysconfig script Macro                 OK
Do you want me to install CentStorage init script ?
[y/n], default to [n]:
> y
CentStorage init script installed                          OK
CentStorage sysconfig script installed                     OK
Do you want me to install CentStorage run level ?
[y/n], default to [n]:
> y
CentStorage Perl lib installed                             OK
Install logAnalyser                                        OK
Install logAnalyserBroker                                  OK
Install nagiosPerfTrace                                    OK
Change macros for centstorage.cron                         OK
Install CentStorage cron                                   OK
Change macros for centstorage.logrotate                    OK
Install Centreon Storage logrotate.d file                  OK
Create /etc/centreon/instCentStorage.conf                  OK
------------------------------------------------------------------------
Start CentCore Installation
------------------------------------------------------------------------
Where is your CentCore binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin                               OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Copy CentCore in binary directory                          OK
Change right : /var/run/centreon                           OK
Change right : /var/lib/centreon                           OK
Change macros for centcore.logrotate                       OK
Install Centreon Core logrotate.d file                     OK
Replace CentCore init script Macro                         OK
Replace CentCore sysconfig script Macro                    OK
Do you want me to install CentCore init script ?
[y/n], default to [n]:
> y
CentCore init script installed                             OK
CentCore sysconfig script installed                        OK
Do you want me to install CentCore run level ?
[y/n], default to [n]:.
> y
CentCore Perl lib installed                                OK
Create /etc/centreon/instCentCore.conf                     OK
------------------------------------------------------------------------
Start CentPlugins Installation
------------------------------------------------------------------------
Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]
> /usr/local/nagios/libexec
Path /usr/local/nagios/libexec                             OK
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
------------------------------------------------------------------------
Start CentPlugins Traps Installation.
------------------------------------------------------------------------
Where is your SNMP configuration directory
default to [/etc/snmp]
>
/etc/snmp                                                  OK
Where is your CentreonTrapd binaries directory
default to [/usr/local/centreon/bin]
>
/usr/local/centreon/bin                                    OK
Finding Apache user :                                      apache
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for snmptrapd.conf                           OK
Replace CentreonTrapd init script Macro                    OK
Replace CentreonTrapd sysconfig script Macro               OK
Do you want me to install CentreonTrapd init script ?
[y/n], default to [n]:
> y
CentreonTrapd init script installed                        OK
CentreonTrapd sysconfig script installed                   OK
Do you want me to install CentreonTrapd run level 
[y/n], default to [n]:
> y
trapd Perl lib installed                                   OK
Install : snmptrapd.conf                                   OK
Install : centreontrapdforward                             OK
Install : centreontrapd                                    OK
Create /etc/centreon/instCentPlugins.conf                  OK
安裝完後,啟動服務


[root@jk centreon-2.5.0]# /etc/init.d/httpd start.
Starting httpd:                                            [  OK  ]
[root@jk centreon-2.5.0]# /etc/init.d/mysqld start
Starting mysqld:                                           [  OK  ]
[root@jk centreon-2.5.0]# mysqladmin -u root -p password 'mysqlpasswd'
[root@jk centreon-2.5.0]# /etc/init.d/ndo2db start
Starting ndo2db: done.
 


 


啟動nrpe

修改/usr/local/nagios/etc/nrpe.cfg
#allowed_hosts=127.0.0.1 這句修改為


allowed_hosts=127.0.0.1,192.168.1.225
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://192.168.1.225/centreon 開啟安裝程式


網頁安裝時,
注意:
資料庫安裝的使用localhost,不要直接使用ip地址,不然回報許可權錯誤,就是有許可權,也會報錯。

nagios 的log 檔案路徑不要修改。/usr/local/nagios/var


後期再修改資料庫等各方面資訊!



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2097961/,如需轉載,請註明出處,否則將追究法律責任。

相關文章