Nagios4.0.4 + Centreon2.5.0安装

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

本例在CentOS 6.5 64位系统测试

1
2
3
rpm -ivh  http: //pkgs .repoforge.org /rpmforge-release/rpmforge-release-0 .5.3-1.el6.rf.x86_64.rpm
yum update
yum upgrade

关闭防火墙和SELINUX

1
2
chkconfig --level 35 iptables off
vi  /etc/selinux/config

将SELINUX=enforcing 修改为:SELINUX=disabled

然后重启系统

reboot


首先安装APACHE 也可根据情况安装NGINX

1
2
yum  install  httpd
usermod  -U apache


安装GD库

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


安装MySQL数据库

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


安装PHP和扩展

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


安装Perl扩展

1
yum  install  perl-Config-IniFiles perl-DBI


安装RRDtool

1
yum  install  rrdtool perl-rrdtool


安装SNMP

1
2
3
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

安装开发库

1
yum groupinstall  "Development Tools"


其他库

1
yum  install  fping glib2-devel


安装PEAR

1
2
3
yum  install  php-pear
pear channel-update pear.php.net
pear upgrade-all


现在我们下载所需用的的软件

1
2
3
4
5
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

1
2
3
4
5
6
7
[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&&make install&&make install-init&&make install-commandmode&&make install-config&&make install-webconf

安装Nagios插件

1
2
3
4
[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

如果出现类似如下错误:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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模块导致  安装

1
yum  install  perl-ExtUtils-MakeMaker

然后再次make&&make install

安装Nrpe

1
2
3
4
5
[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

1
2
3
4
5
6
7
8
[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)的内容 修改成以下内容:


1
2
3
4
5
6
7
8
9
10
11
12
13
[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

1
2
3
4
[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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
------------------------------------------------------------------------
         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 ]
>
Do you want me to create this directory ? [ /etc/centreon ]
[y /n ], default to [n]:
> y
Path  /etc/centreon                                          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 ]
>
Do you want me to create this directory ? [ /var/lib/centreon ]
[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/log
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 [ /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
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

装完后,启动服务

1
2
3
4
5
6
7
[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 打开安装程序

如图:

wKiom1NGXM_BT0CHAACuKl5Oigw656.jpg

wKiom1NGXWLxxk6rAAC1AjEKAiE917.jpg

填写正确的路径

wKioL1NGXTqC2tMhAADHQKFHqbI691.jpg

填写管理员密码和邮箱

wKiom1NGXWOQ9Z1vAADFncMXXyY239.jpg

填写数据库用户名和密码

wKioL1NGXTqBmEa-AAD4zYYLLEk286.jpg遇到下面这个错误

在/etc/my.cn 的MYSQLD段添加下面一句

innodb_file_per_table=1

然后重新启动MYSQL

service mysqld restart

wKiom1NGXWORFtvcAAC6f1OjGoI336.jpg

wKiom1NGXWOBxQqnAAC-07wH1w0889.jpg

wKioL1NGXTuBa9p1AACsBI5U3qg290.jpg

wKiom1NGXWORTf-IAACAriE_W7g805.jpg

Configuration->Monitoring Engines->Generate 勾选所有,然后点击Export

wKioL1NGXTvjNDtWAAGG8r9N-yI795.jpg



先把默认服务删除

添加一个check_ping命令

$USER1$/check_ping  -H $HOSTADDRESS$  -w $ARG1$ -c $ARG2$ -p $ARG3$

wKiom1NGXWTiQdC3AAIHkIUIfsg635.jpg

Configuration->Commands->Add

$USER1$/check_ping  -H $HOSTADDRESS$  -w $ARG1$ -c $ARG2$ -p $ARG3$

wKioL1NGXTyAea8WAAF2-pvYQZ0675.jpg

接着添加一个服务模板

Configuration->Services-Templates->Add

wKiom1NGXWWiGQOsAAG3lwiV--Y742.jpg

检查是否正确并生成配置:管理-》nagios 勾选所有动作-》导出

再添加一个命令check_nrpe ,Configuration->Commands->Add

$USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$


wKioL1NGXTzwX-orAAFdScPucDg849.jpg

下面添加服务

配置-》服务-》模板-》增加

添加check_load

wKioL1NGYEOjipUbAAHJWbLnyCk969.jpg

添加check_users

wKiom1NGYGyRyzTbAAGT2fuz3R8030.jpg

添加check_ disk

wKioL1NGYEPiH-ZhAAHhYuJrj8s767.jpg

添加check_zombie_procs

wKiom1NGYGySw6GQAAGRH1Sp2rY064.jpg

添加check_total_procs

wKioL1NGYETBua6BAAHilviD9vk782.jpg

关联模板:因为 Centreon-Server继承的是Servers-Linux主机模板,所以我们在Servers-Linux模板里将刚才的服务模板都关联上

wKioL1NGYPujDyYlAAFUwNom108144.jpg

检查是否正确并生成配置:管理-》nagios 勾选所有动作-》导出

过一会 如下图

wKiom1NGYUWiGlmWAAGu101mrcw304.jpg

下面说说nrpe监控WINDOWS

首先现在NRPE客户端 下载地址如下:

http://nsclient.org/nscp/downloads

在这里我们下载的是NSCP-0.4.2.88-x64.msi

然后安装这个软件

wKioL1NGYXPQoLEvAACvfK_ukuw446.jpg

wKiom1NGYZvQ4AqvAABzPmnApRw906.jpg

wKioL1NGYXPQSp8JAACocrrqSPU853.jpg

由于系统自带check_nt_cpu /check_nt_disk/check_memuse 我们再添加两个

添加一个check_nt_uptime命令

$USER1$/check_nt -H $HOSTADDRESS$ -p $ARG1$ -v UPTIME -s $ARG2$

wKioL1NGZNrybKfOAAFR3WsXhc8380.jpg

再添加一个check_nt_service命令

$USER1$/check_nt -H $HOSTADDRESS$ -p $ARG1$ -v SERVICESTATE -d SHOWALL -l $ARG2$ -s $ARG3$

wKiom1NGZU2h_r1MAAF8_Tu46o4556.jpg

添加完成后我们依次添加服务模板

添加check_nt_cpu

wKiom1NGZkWAyrpqAAFSHutnJ7s712.jpg

添加check_nt_disk

wKioL1NGZhyyuLT6AAEoDbjJxA8575.jpg

添加check_nt_mem

wKiom1NGZkXQAc0sAAEeCIv4_ag418.jpg

添加check_nt_uptime

wKioL1NGZhziyKS9AAESIydUrz0527.jpg

添加check_nt_services

wKiom1NGZkWApOfnAAFYXbVdwpc849.jpg

添加完成后我们添加一台WINDOWS主机

wKioL1NGZvuAdvWzAAGYuKL1vv0426.jpg

添加完成后我们关联模板

wKiom1NGZ2vDIn6lAAFADR47Ah4493.jpg

wKioL1NGZ9mQGwNFAADz4lqQRIg991.jpg

检查是否正确并生成配置:管理-》nagios 勾选所有动作-》导出

过一会儿如下:

wKiom1NGaELgbb5hAAJfrAsKWKo259.jpg

我们现在说说批量添加  这个要用脚本

脚本名称 add_host.pl

内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl
## ====================================================
use  strict;
use  warnings;
use  DBI;
use  DBD::mysql;
# ----------------------------------------------------
my  $DB_HOST  "127.0.0.1" ; //数据IP
my  $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 set
host_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.222webserver1

192.168.1.223webserver2

.........

这个脚本只能批量添加主机无法添加服务,所以我们还得安装centreon-clapi

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[root@jk soft]# tar xvzf centreon-clapi-1.5.2.tar.gz
[root@jk soft]# cd centreon-clapi-1.5.2
[root@jk centreon-clapi-1.5.2]# ./install.sh -i
##############################################################################
#
#                                                                             #
#              Module : Centreon CLAPI version 1.5                    #
#                                                                             #
##############################################################################
#
------------------------------------------------------------------------
         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
------------------------------------------------------------------------
         Load parameters
------------------------------------------------------------------------
Please specify the directory that contains  "instCentWeb.conf"
> /etc/centreon/
------------------------------------------------------------------------
         Centreon CLAPI Module Installation
------------------------------------------------------------------------
Replacing macros                                           OK
Setting right                                              OK
Setting owner/group                                        OK
Create module directory                                    OK
Copying module                                             OK
Delete temp install directory                              OK
The centreon-clapi.1.5 installation is finished            OK
[root@jk centreon-clapi-1.5.2]#
cd /usr/local/centreon/www/modules/centreon-clapi/core/
vi centreon

require_once "$centreon_etc/centreon.conf.php";

改为

require_once "/etc/centreon/centreon.conf.php";

查看主机

[root@jk core]# ./centreon -uadmin -p111222 -o HOST -a show

id;name;alias;address;activate

14;Centreon-Server;Monitoring Server;127.0.0.1;1

16;windows;windows;192.168.1.254;1


应用关联模板 对WebServer1应用模板

./centreon -uadmin -p111111 -o HOST -a applytpl -v "WebServer1"




设置引导自动启动服务

[root@jk ~]# chkconfig --level 345 nagios on

[root@jk ~]# chkconfig --level 345 centcore on

[root@jk ~]# chkconfig --level 345 centstorage on

[root@jk ~]# chkconfig --level 345 ndo2db on

[root@jk ~]# chkconfig --level 345 httpd on

[root@jk ~]# chkconfig --level 345 mysqld on



[root@jk var]# service centstorage restart

Stopping centstorage:                                      [FAILED]

Starting centstorage:                                      [  OK  ]


这个服务一直启动不起来,多方测试均不可以 如下方法解决

/usr/bin/perl /usr/local/centreon/bin/centstorage --logfile=/usr/local/centreon/log/centstorage.log --severity=error


--config=/etc/centreon/conf.pm &

这样启动



如果要查看Nagios的页面要新建一个用户 如下  用户名必须是nagiosadmin


[root@jk ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

New password:

Re-type new password:

Adding password for user nagiosadmin

[root@jk ~]#

现在可以通过http://www.xxx.com/nagios访问


如果Poller States 红色状态,请查看/var/log/message

jk 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 -p

  use 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 = 431072000

kernel.msgmni = 100000

kernel.msgmax = 6553600


修改完成之后 sysctl -p


汉化

1
2
3
mkdir -p /usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
cd /usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
wget http: //cacti-nagios.googlecode.com/files/messages.mo

然后再页面里面更改 如下图:

wKiom1NQkf2jYPMcAAFPQ18LbUY958.jpg

如果还有其他错误  请检查nagios配置一些路径 在网页端对照一下





      本文转自flyingzf  51CTO博客,原文链接:http://blog.51cto.com/flyingzf/1393548,如需转载请自行联系原作者





相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
数据采集 监控 Unix
Cacti/Nagios/Zabbix/centreon/Ganglia之抉择
一、Cacti 二、Nagios 三、Zabbix 四、Ganglia 五、Centreon 六、对比图
|
Web App开发 开发工具 机器学习/深度学习
|
监控 网络协议 测试技术
|
Web App开发 开发工具 机器学习/深度学习
|
监控 关系型数据库 MySQL