435retr 发表于 2014-4-11 10:13:54

Nagios4.0.4 + Centreon2.5.0安装

本例在CentOS 6.5 64位系统测试


rpm -ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum update
yum upgrade
关闭防火墙和SELINUX


chkconfig --level 35 iptables off
vi /etc/selinux/config
将SELINUX=enforcing 修改为:SELINUX=disabled
然后重启系统
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 http://jaist.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.4/nagios-4.0.4.tar.gz
wget http://jaist.dl.sourceforge.net/project/nagios/ndoutils-2.x/ndoutils-2.0.0/ndoutils-2.0.0.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
wget http://download.centreon.com/centreon/centreon-2.5.0.tar.gz
wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
centreon-clapi-1.5.2 下载地址 http://download.centreon.com/index.php?id=4296
安装Nagios


# useradd nagios
# groupadd nagcmd
# usermod -G nagios,nagcmd nagios
# tar xvzf nagios-4.0.4.tar.gz
# cd nagios-4.0.4
# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd --enable-nanosleep --enable-event-broker --enable-embedded-perl
# make all&&make install&&make install-init&&make install-commandmode&&make install-config&&make install-webconf
安装Nagios插件


# cd ..
# tar xvzf nagios-plugins-2.0.tar.gz
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules
# 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: Entering directory `/soft/nagios-plugins-2.0/perlmods/Test-Simple-0.98'
make: *** No targets specified and no makefile found.Stop.
make: 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: *** Error 2
make: Leaving directory `/soft/nagios-plugins-2.0/perlmods'
make: *** Error 1
make: Leaving directory `/soft/nagios-plugins-2.0'
make: *** Error 2

这个是缺少Perl模块导致安装
yum install perl-ExtUtils-MakeMaker
然后再次make&&make install
安装Nrpe


# cd ..
# tar xvzf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure
# make all&&make install-plugin&&make install-daemon&&make install-daemon-config
安装Ndoutils


# cd ..
# tar xvzf ndoutils-2.0.0.tar.gz
# cd ndoutils-2.0.0
# ./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
修改启动脚本killproc_ndo2db()和 stop)的内容 修改成以下内容:



# 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
         ;;
# chmod +x /etc/init.d/ndo2db
# chkconfig --add ndo2db
# chkconfig --level 345 ndo2db on

安装Centreon


# cd ../
# tar xvzf centreon-2.5.0.tar.gz
# cd 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 ?
, default to :
> y
------------------------------------------------------------------------
      Please choose what you want to install
------------------------------------------------------------------------
Do you want to install : Centreon Web Front
, default to :
> y
Do you want to install : Centreon CentCore
, default to :
> y
Do you want to install : Centreon Nagios Plugins
, default to :
> y
Do you want to install : Centreon Snmp Traps process
, default to :
> y
------------------------------------------------------------------------
      Start CentWeb Installation
------------------------------------------------------------------------
Where is your Centreon directory?
default to
>
Do you want me to create this directory ?
, default to :
> y
Path /usr/local/centreon                                 OK
Where is your Centreon log directory
default to
>
Do you want me to create this directory ?
, default to :
> y
Path /usr/local/centreon/log                               OK
Where is your Centreon etc directory
default to
>
Do you want me to create this directory ?
, default to :
> y
Path /etc/centreon                                       OK
Where is your Centreon binaries directory
default to
>
Do you want me to create this directory ?
, default to :
> y
Path /usr/local/centreon/bin                               OK
Where is your Centreon data informations directory
default to
>
Do you want me to create this directory ?
, default to :
> y
Path /usr/local/centreon/data                              OK
Where is your Centreon variable library directory?
default to
>
Do you want me to create this directory ?
, default to :
> y
Path /var/lib/centreon                                     OK
/usr/bin/rrdtool                                           OK
/bin/mail                                                OK
/usr/bin/php                                             OK
Where is PEAR
default to
> /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 ?
default to
>
Do you want me to create this group ?
, default to :
> y
What is the Centreon user ?
default to
>
Do you want me to create this user ?
, default to :
> 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/log
Where is your monitoring plugins (libexec) directory ?
default to
> /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                                             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)
, default to :
> y
Configuring Sudo                                           OK
      Configure Apache server
------------------------------------------------------------------------
Do you want to add Centreon Apache sub configuration file ?
, default to :
> y
Create '/etc/httpd/conf.d/centreon.conf'                   OK
Configuring Apache                                       OK
Do you want to reload your Apache ?
, default to :
> 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
, default to :
> 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
>
Do you want me to create this directory ?
, default to :
> y
Path /var/run/centreon                                     OK
Where is your CentStorage binary directory
default to
>
Path /usr/local/centreon/bin                               OK
Where is your CentStorage RRD directory
default to
>
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 ?
, default to :
> y
CentStorage init script installed                        OK
CentStorage sysconfig script installed                     OK
Do you want me to install CentStorage run level ?
, default to :
> 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
>
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 ?
, default to :
> y
CentCore init script installed                           OK
CentCore sysconfig script installed                        OK
Do you want me to install CentCore run level ?
, default to :
> y
CentCore Perl lib installed                              OK
Create /etc/centreon/instCentCore.conf                     OK
------------------------------------------------------------------------
      Start CentPlugins Installation
------------------------------------------------------------------------
Where is your CentPlugins lib directory
default to
> /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                                                OK
Where is your CentreonTrapd binaries directory
default to
>
/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 ?
, default to :
> y
CentreonTrapd init script installed                        OK
CentreonTrapd sysconfig script installed                   OK
Do you want me to install CentreonTrapd run level ?
, default to :
> y
trapd Perl lib installed                                 OK
Install : snmptrapd.conf                                 OK
Install : centreontrapdforward                           OK
Install : centreontrapd                                    OK
Create /etc/centreon/instCentPlugins.conf                  OK
安装完后,启动服务


# /etc/init.d/httpd start
Starting httpd:                                          
# /etc/init.d/mysqld start
Starting mysqld:                                          
# mysqladmin -u root -p password 'mysqlpasswd'
# /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=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1这句修改如下
command=/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 打开安装程序
如图:填写正确的路径填写管理员密码和邮箱填写数据库用户名和密码遇到下面这个错误在/etc/my.cn 的MYSQLD段添加下面一句innodb_file_per_table=1然后重新启动MYSQLservice mysqld restartConfiguration->Monitoring Engines->Generate 勾选所有,然后点击Export

先把默认服务删除添加一个check_ping命令$USER1$/check_ping-H $HOSTADDRESS$-w $ARG1$ -c $ARG2$ -p $ARG3$Configuration->Commands->Add$USER1$/check_ping-H $HOSTADDRESS$-w $ARG1$ -c $ARG2$ -p $ARG3$接着添加一个服务模板Configuration->Services-Templates->Add检查是否正确并生成配置:管理-》nagios 勾选所有动作-》导出再添加一个命令check_nrpe ,Configuration->Commands->Add$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
下面添加服务配置-》服务-》模板-》增加添加check_load添加check_users添加check_ disk添加check_zombie_procs添加check_total_procs关联模板:因为 Centreon-Server继承的是Servers-Linux主机模板,所以我们在Servers-Linux模板里将刚才的服务模板都关联上检查是否正确并生成配置:管理-》nagios 勾选所有动作-》导出过一会 如下图下面说说nrpe监控WINDOWS首先现在NRPE客户端 下载地址如下:http://nsclient.org/nscp/downloads在这里我们下载的是NSCP-0.4.2.88-x64.msi然后安装这个软件由于系统自带check_nt_cpu /check_nt_disk/check_memuse 我们再添加两个添加一个check_nt_uptime命令$USER1$/check_nt -H $HOSTADDRESS$ -p $ARG1$ -v UPTIME -s $ARG2$再添加一个check_nt_service命令$USER1$/check_nt -H $HOSTADDRESS$ -p $ARG1$ -v SERVICESTATE -d SHOWALL -l $ARG2$ -s $ARG3$添加完成后我们依次添加服务模板添加check_nt_cpu添加check_nt_disk添加check_nt_mem添加check_nt_uptime添加check_nt_services添加完成后我们添加一台WINDOWS主机添加完成后我们关联模板检查是否正确并生成配置:管理-》nagios 勾选所有动作-》导出过一会儿如下:我们现在说说批量添加这个要用脚本脚本名称 add_host.pl内容如下:

#!/usr/bin/perl## ====================================================use strict;use warnings;use DBI;use DBD::mysql;# ----------------------------------------------------my $DB_HOST = "127.0.0.1"; //数据IPmy $DB_USER = "root"; //数据库用户名my $DB_PASSWD = "passwd"; //数据库密码my $DB_NAME = "centreon"; //数据库名称my $dbh = DBI->connect("DBI:mysql:database=$DB_NAME;host=$DB_HOST",                     "$DB_USER", "$DB_PASSWD", { RaiseError => 1 });# ----------------------------------------------------my $file_path = "./hosts";//HOST文件my $tpl_name = "Servers-Linux";//模板my $nagios_name = "Central";foreach my $arg (@ARGV) {    # == file of hostname and ipaddress ==    if ($arg eq '-f') {      $file_path = shift;      }    # == name of template ==    elsif ($arg eq '-t') {      $tpl_name = shift;      }    # == name of nagios name ==    elsif ($arg eq '-n') {      $nagios_name = shift;      }    else {      &print_help();      exit 1;      }    }# -----------------------------------------------------open (HOST, "$file_path") || die "Cannot open $file_path for read";my $sql;my $sth;my $line;my ($host, $ipaddr);my ($host_id, $tpl_id, $nagios_id) = (0, 0, 0);while (defined($line = <HOST>)) {    # == skip blank lines =================    next if ($line =~ /^\s*$/);    # == skip if # ========================    next if ($line =~ /^\s*#/);    # == get host and ipaddress ===========    ($ipaddr, $host) = split(/\s+/, $line);    next if ($ipaddr eq '' || $host eq '');    # == insert the host to table host ====    $sql = "insert host sethost_template_model_htm_id='2',host_name='$host',host_alias='$host',host_address='$ipaddr',host_active_checks_enabled='2',host_passive_checks_enabled='2',host_checks_enabled='2',host_event_handler_enabled='2',host_flap_detection_enabled='2',host_process_perf_data='2',host_retain_status_information='2',host_retain_nonstatus_information='2',host_notifications_enabled='2',host_register='1',host_activate='1'";    $sth = $dbh->do($sql);    sleep(1);    # == get host_id ======================    $sql = "select host_id from host where host_name='$host'";    $sth = $dbh->prepare($sql);      $sth->execute();    while (my $ref = $sth->fetchrow_hashref()) {               $host_id = $ref->{'host_id'};            print "host_id is $host_id\n";                        }      next if ($host_id == 0);    # == insert extended_host_information ==    $sql = "insert extended_host_information set host_host_id='$host_id'";    $sth = $dbh->do($sql);    # == insert host_template_relation =====    $sql = "select host_id from host where host_name='$tpl_name'";    $sth = $dbh->prepare($sql);      $sth->execute();    while (my $ref = $sth->fetchrow_hashref()) {                        $tpl_id = $ref->{'host_id'};            print "template id is $tpl_id\n";                        }      next if ($tpl_id == 0);    $sql = "insert host_template_relation set host_host_id='$host_id',host_tpl_id='$tpl_id',`order`='1'";    $sth = $dbh->prepare($sql);      $sth->execute();    # == insert ns_host_relation ===========    $sql = "select id from nagios_server where name='$nagios_name'";      $sth = $dbh->prepare($sql);      $sth->execute();      while (my $ref = $sth->fetchrow_hashref()) {                        $nagios_id = $ref->{'id'};            print "nagios id is $nagios_id\n";                        }      next if ($nagios_id == 0);      $sql = "insert ns_host_relation set host_host_id='$host_id',nagios_server_id='$nagios_id'";      $sth = $dbh->prepare($sql);      $sth->execute();    # == insert complete ==    print "insert $host to centreon complete\n";    }close(HOST);$dbh->disconnect();exit 0;# --------------------------------------------------------------------------------sub print_help {    print "Usage ./insert_host.pl [-f path of host file] [-n nagios name] [-t template name]\n";    print "\n";    }
hosts文件格式如下:192.168.1.222webserver1192.168.1.223webserver2.........这个脚本只能批量添加主机无法添加服务,所以我们还得安装centreon-clapi

# tar xvzf centreon-clapi-1.5.2.tar.gz# cd centreon-clapi-1.5.2# ./install.sh -i################################################################################                                                                           ##            Module : Centreon CLAPI version 1.5                  ##                                                                           ################################################################################------------------------------------------------------------------------      Checking all needed binaries------------------------------------------------------------------------rm                                                         OKcp                                                         OKmv                                                         OK/bin/chmod                                                 OK/bin/chown                                                 OKecho                                                       OKmore                                                       OKmkdir                                                      OKfind                                                       OK/bin/grep                                                OK/bin/cat                                                   OK/bin/sed                                                   OK------------------------------------------------------------------------      Load parameters------------------------------------------------------------------------Please specify the directory that contains "instCentWeb.conf"> /etc/centreon/------------------------------------------------------------------------      Centreon CLAPI Module Installation------------------------------------------------------------------------Replacing macros                                           OKSetting right                                              OKSetting owner/group                                        OKCreate module directory                                    OKCopying module                                             OKDelete temp install directory                              OKThe centreon-clapi.1.5 installation is finished            OK#cd /usr/local/centreon/www/modules/centreon-clapi/core/vi centreonrequire_once "$centreon_etc/centreon.conf.php";改为require_once "/etc/centreon/centreon.conf.php";查看主机# ./centreon -uadmin -p111222 -o HOST -a showid;name;alias;address;activate14;Centreon-Server;Monitoring Server;127.0.0.1;116;windows;windows;192.168.1.254;1
应用关联模板 对WebServer1应用模板./centreon -uadmin -p111111 -o HOST -a applytpl -v "WebServer1"


设置引导自动启动服务# chkconfig --level 345 nagios on# chkconfig --level 345 centcore on# chkconfig --level 345 centstorage on# chkconfig --level 345 ndo2db on# chkconfig --level 345 httpd on# chkconfig --level 345 mysqld on

# service centstorage restartStopping centstorage:                                    Starting centstorage:                                    
这个服务一直启动不起来,多方测试均不可以 如下方法解决/usr/bin/perl /usr/local/centreon/bin/centstorage --logfile=/usr/local/centreon/log/centstorage.log --severity=error
--config=/etc/centreon/conf.pm &这样启动

如果要查看Nagios的页面要新建一个用户 如下用户名必须是nagiosadmin
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadminNew password:Re-type new password:Adding password for user nagiosadmin#现在可以通过http://www.xxx.com/nagios访问
如果Poller States 红色状态,请查看/var/log/messagejk ndo2db: mysql_error: 'Unknown column 'importance' in 'field list''如果有类似上面的错误,请重新新建一个nagios的数据库到ndoutils-2.0.0的安装目录的 db目录本例是/soft/ndoutils-2.0.0/db执行
./installdb -u root -p passwd -h localhost -d nagios改成自己的mysql的用户名和密码改完之后请在NDO2DB.CFG修改数据库名为nagios查看/usr/local/centreon/log/sql-error.log文件 如果有以下错误2014-04-10 13:36|0|0|DB Error: no such table QUERY : DELETE FROM centreon_acl WHERE group_id NOT IN (SELECT
DISTINCT acl_group_id FROM centreon.acl_res_group_relations)这个是缺少个字段 解决办法如下:
mysql -u root -puse nagios;
CREATE TABLE IF NOT EXISTS `centreon_acl` ( `id` int(11) NOT NULL auto_increment, `host_name` varchar(255) default NULL, `service_description` varchar(255) default NULL, `group_id` int(11) default NULL, PRIMARY KEY (`id`), KEY `host_name` (`host_name`), KEY `service_description` (`service_description`), KEY `group_id` (`group_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
如果系统日志不显示NOD2DB的相关日志系统日志提示如下:ndo2db: Warning: Retrying message send. This can occur because you have too few messages allowed or too few
total bytes allowed in message queues. You are currently using 64 of 3739 messages and 65536 of 65536 bytes in the
queue. See README for kernel tuning options.
那么修改 /etc/sysctl.conf如果没有则添加,如果有则修改数值kernel.msgmnb = 431072000kernel.msgmni = 100000kernel.msgmax = 6553600
修改完成之后 sysctl -p

ops2003 发表于 2014-11-9 21:59:44

NRPE2.15与 nagios4.X 兼容性 你测试 过行吗?我之前安装后测试一直有问题

官方文档上没有兼容nagios 4.X :
Current Version2.15
Last Release Date2013-09-06
Compatible With
Nagios 1.x
Nagios 2.x
Nagios 3.x

but not nagios4.X

geniusjoy 发表于 2014-11-10 00:04:24

死神的沙漏 发表于 2014-11-15 02:50:46

够详细,我一个菜鸟都装起了,不过弱弱的问一下,有中文的web界面不?

bin2bing 发表于 2015-5-25 10:54:35

安装centreon完成后配置的时候
第一步加个check_ping的命令
但接下来我就遇到问题了
在加服务模版的时候args这里没有参数的框?
是我哪里操作不多吗
我这次是按这个的步骤来的 ,上次下载了cnyunwei V11版的centreon也这样
搞不懂了求大神们帮助啊
页: [1]
查看完整版本: Nagios4.0.4 + Centreon2.5.0安装