12年 linux 系统运维工程师,网络架构设计、优化,故障处理。
分类: 系统运维
2013-04-26 18:00:26
LAMP+Nagios+Ndoutils+Centreon 64位操作系统安装
LAMP安装
安装yum 源
1. rpm -ivh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
2. rpm -ivh epel-release-5-4.noarch.rpm
3. rpm -ivh remi-release-5-8.el5.remi.noarch.rpm
yum安装:
#yum install httpd
#yum install mysql mysql-server mysql-devel openssl-devel perl-DBD-MySQL
#yum install php php-mysql php-gd
部分软件包安装
安装 PHP附属包:
#yum install php-pear php-snmp php-common php-ldap php-xml php-gd php-mbstring
安装PERl包:
#yum install perl-DBI perl-Config-IniFiles perl-Crypt-DES perl-Digest-HMAC perl-Digest-SHA1 perl-GD perl-IO-Socket-INET6 perl-Net-SNMP perl-rrdtool perl-Socket6 perl-Config-IniFiles
安装GD Modules:
#yum install gd gd-devel
安装其余软件包:
#yum install libpng-devel dmidecode lm_sensors libpng zlib freetype cairo pango libxml2 fontconfig fping graphviz gcc-c++ glib2-devel
Yum install glib
Yum install fping
Yum install graphviz.x86_64
以上软件包如果本机中未能自带,请登录 上自行下载。
(当需要安装librrd.so.2()(64bit时,下载zenoss-2.3.3.el5.x86_64.rpm
安装RRDTOOL:
rpm -e rrdtool-1.4.7-1.el5.rf.x86_64 perl-rrdtool-1.4.7-1.el5.rf.x86_64
#rpm –ivh rrdtool-1.2.19-1.el5.kb.x86_64.rpm
#rpm –ivh rrdtool-devel-1.2.19-1.el5.kb.x86_64.rpm
#rpm –ivh rrdtool-doc-1.2.19-1.el5.kb.x86_64.rpm
#rpm –ivh rrdtool-perl-1.2.19-1.el5.kb.x86_64.rpm
#rpm –ivh rrdtool-php-1.2.19-1.el5.kb.x86_64.rpm
#rpm –ivh rrdtool-python-1.2.19-1.el5.kb.x86_64.rpm
#rpm –ivh rrdtool-tcl-1.2.19-1.el5.kb.x86_64.rpm
安装PEAR模块:
因为之前已经安装过php-pear包,pear的主目录已经产生,但是Centreon还需要加载一些pear模块才能工作。
pear upgrade --force
#pear install Archive_Tar Auth_SASL Console_Getopt Date DB DB_DataObject DB_DataObject_FormBuilder HTML_Common HTML_QuickForm_advmultiselect HTML_QuickForm_ElementGrid HTML_Table HTML_QuickForm HTTP HTTP_Request Image_Canvas Image_Color Image_Graph Image_GraphViz Log Mail Mail_Mime Math_BigInteger MDB2 Net_DIME Net_IDNA Net_Ping Net_SMTP Net_Socket Net_Traceroute Net_URL Numbers_Roman Numbers_Words SOAP Structures_Graph Validate XML_RPC
#pear list ------ 查看安装了哪些模块
pear install channel://pear.php.net/Image_Canvas-0.3.5
pear install channel://pear.php.net/Image_Graph-0.8.0
pear install channel://pear.php.net/Numbers_Words-0.16.4
pear install channel://pear.php.net/SOAP-0.13.0
pear install channel://pear.php.net/Validate-0.8.5
pear install channel://pear.php.net/HTML_QuickForm_ElementGrid-0.1.2
pear install channel://pear.php.net/NET_IDNA-0.8.1
pear install channel://pear.php.net/Net_Traceroute-0.21.3
安装SNMP:
#yum install net-snmp net-snmp-utils net-snmp-devel net-snmp-perl
配置SNMP:
#vim /etc/snmp/snmpd.conf 将x.x.x.x换成运行nagios服务器的IP地址:
com2sec notConfigUser x.x.x.x public
access notConfigGroup”” any noauth exact all none none
view all included .1 80
安装nagios Ndoutils安装
=====================yum 安装===================
yum install nagios nagios-plugins nagios-plugins-nrpe nagios-devel nagios-nrpe nagios
安装完的插件都在/usr/lib64/nagios/plugins下,以后centreon插件也会在这个目录下。
输入 可以看到如下界面:
/usr/bin/htpasswd -c /etc/nagios/htpasswd.users nagios (如无法登陆需设置用户名密码、用户名或为nagiosadmin)
设置密码
#出现这个画面表示nagios安装成功
#执行service nagios start操作可以看到nagios监控的本机的状态
(nagios目录:/etc/nagios/
插件目录:/usr/lib64/nagios/plugins
给nagios用户开权限,让他能够查看信息!
# vim /usr/local/nagios/etc/cgi.cfg
在所有的nagiosadmin后面添加nagios
/etc/init.d/nrpe start)
Ndoutils安装
#tar -zxf ndoutils-1.4b9.tar.gz
#cd ndoutils-1.4b9
#./configure --prefix=/usr/local/nagios/ \
--enable-mysql \
--disable-pgsql \
--with-ndo2db-user=nagios \
--with-ndo2db-group=nagios
#make
#make install
Cd config
Copy ndo2db.cfg to /etc/nagios/ndo2db.cfg
##### find that file from current monitoring machine!!!!!!!!!!!
(启动ndo2db守护进程
/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
对于不同Nagios版本,NDOUtils有不同的启动程序,ndo2db-2x对应Nagios的2.X版本,ndo2db-3x对应Nagios的3.X版本,
)
Centreon安装
#tar -zxf centreon-2.1.9.tar.gz
#cd centreon-2.1.9
#./install.sh -i
#每一步都要看好要安装的东西以及目录,安装目录默认的就选默认就好了,有的需要自己指定目录:RRDs,PEAR.php,ndomod.o
#find / -name RRDs.pm
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/RRDs.pm
#find / -name PEAR.php
/usr/share/pear/PEAR.php
/usr/lib64/nagios
/etc/nagios
/var/nagios
#find / -name ndomod.o
/usr/local/nagios/bin/ndomod.o
# ./install.sh –i
Centreon安装完成后,你可以通过来访问。
Is running 无法启动时
执行 /usr/sbin/ndo2db -c /etc/nagios/ndo2db.cfg
#安装后在网址中输入 进入Centreon web 配置界面
#填写mysql数据库访问密码,填写ndo的用户及密码
#创建centreon登录时的账号和密码
#登录后的界面:
#安装完成
C、配置cgi.cfg
D、应用更改
问题解决:
解决不能显示服务及host的数量
添加默认的用户名
参考:
[root@localhost centreon-2.2.2]# ./install.sh -i
###############################################################################
# #
# Centreon () #
# Thanks for using Centreon #
# #
# v2.2 #
# #
# infos@centreon.com #
# #
# Make sure you have installed and configured #
# sudo - sed - php - apache - rrdtool - mysql #
# #
###############################################################################
------------------------------------------------------------------------
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.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
..............................................................................................................................................
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]
>
Path /etc/centreon OK
Where is your Centreon generation_files directory?
default to [/usr/local/centreon]
>
Path /usr/local/centreon OK
Where is your Centreon variable library directory?
default to [/var/lib/centreon]
>
Path /var/lib/centreon OK
Where is your CentPlugins Traps binary
default to [/usr/local/centreon/bin]
>
Do you want me to create this directory ? [/usr/local/centreon/bin]
[y/n], default to [n]:
> y
Path /usr/local/centreon/bin OK
Where is the RRD perl module installed [RRDs.pm]
default to [/usr/lib/perl5/RRDs.pm]
> /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/RRDs.pm
Path /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-threadOKulti
/usr/bin/rrdtool OK
/bin/mail OK
Where is PEAR [PEAR.php]
default to [/usr/share/php/PEAR.php]
> /usr/share/pear/PEAR.php
Path /usr/share/pear OK
Where is installed Nagios ?
default to [/usr/local/nagios]
> /usr/lib64/nagios
Path /usr/lib64/nagios OK
Where is your nagios config directory
default to [/usr/local/nagios/etc]
> /etc/nagios
Path /etc/nagios OK
Where is your Nagios var directory ?
default to [/usr/local/nagios/var]
> /var/nagios
Path /var/nagios OK
Where is your Nagios plugins (libexec) directory ?
default to [/usr/local/nagios/libexec]
> /usr/lib64/nagios/plugins
Path /usr/lib64/nagios/plugins OK
/usr/bin/nagios OK
Where is your Nagios image directory ?
default to [/usr/local/nagios/share/images/logos]
> /usr/share/nagios/images/logos
Path /usr/share/nagios/images/logos OK
/usr/bin/nagiostats OK
p1_file : /usr/bin/p1.pl OK
/usr/bin/php OK
/usr/bin/perl OK
Finding Apache group : apache
Finding Apache user : apache
Finding Nagios user : nagios
Finding Nagios group : nagios
Where is your NDO ndomod binary ?
default to [/usr/sbin/ndomod.o]
> /usr/local/nagios/bin/ndomod.o
/usr/local/nagios/bin/ndomod.o OK
------------------------------------------------------------------------
Configure Sudo
------------------------------------------------------------------------
Where is sudo configuration file
default to [/etc/sudoers]
>
/etc/sudoers OK
Nagios init script OK
Your sudo has been configured previously
Do you want me to reconfigure your sudo ? (WARNING)
[y/n], default to [n]:
> y
Configuring Sudo OK
------------------------------------------------------------------------
Configure Apache server
------------------------------------------------------------------------
Finding Apache Centreon configuration file
'/etc/httpd/conf.d/centreon.conf' : OK
Do you want to update Centreon Apache sub configuration file ?
[y/n], default to [n]:
> y
Backup Centreon Apache configuration completed
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 OK
Preparing Centreon temporary files
Change right on /usr/local/centreon/log OK
Change right on /etc/centreon OK
Change right on /usr/share/nagios/images/logos OK
Install nagios documentation OK
Change macros for insertBaseConf.sql OK
Change macros for php files OK
Change right on /etc/nagios OK
Copy CentWeb in system directory
Install CentWeb (web front of centreon) OK
Install libraries OK
Copying libinstall OK
Change macros for centreon.cron OK
Install Centreon cron.d file OK
Change macros for archiveDayLog OK
Change macros for centAcl.php OK
Install cron directory OK
------------------------------------------------------------------------
Pear Modules
------------------------------------------------------------------------
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.9.6 OK
DB_DataObject_FormBuilder 1.0.0RC4 1.0.1 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.1 OK
Auth_SASL 1.0.1 1.0.6 OK
Console_Getopt 1.2 1.2 OK
Net_SMTP 1.2.8 1.6.1 OK
Net_Socket 1.0.1 1.0.10 OK
Net_Traceroute 0.21 0.21.3 OK
Net_Ping 2.4.1 2.4.5 OK
Validate 0.6.2 0.8.4 OK
XML_RPC 1.4.5 1.5.0 OK
SOAP 0.10.1 0.12.0 OK
Log 1.9.11 1.12.7 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]
>
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
Finding Nagios group : nagios
Finding Nagios user : nagios
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
install www/install/createTablesCentstorage.sql OK
CentStorage status Directory already exists PASSED
CentStorage metrics Directory already exists PASSED
Change macros for centstorage binary OK
Install CentStorage binary OK
Install library for centstorage OK
Change right : /var/run/centreon OK
Change macros for centstorage init script OK
Do you want me to install CentStorage init script ?
[y/n], default to [n]:
> y
CentStorage init script installed OK
Do you want me to install CentStorage run level ?
[y/n], default to [n]:
> y
Change macros for logAnalyser OK
Install logAnalyser OK
Change macros for nagiosPerfTrace OK
Install nagiosPerfTrace OK
Change macros for purgeLogs OK
Install purgeLogs OK
Change macros for purgeCentstorage OK
Install purgeCentstorage OK
Change macros for centreonPurge.sh OK
Install centreonPurge.sh OK
Change macros for centstorage.cron OK
Install CentStorage cron OK
Create /etc/centreon/instCentStorage.conf OK
------------------------------------------------------------------------
Start CentCore Installation
------------------------------------------------------------------------
Where is your CentCore binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin OK
/usr/bin/ssh OK
/usr/bin/scp OK
Finding Nagios group : nagios
Finding Nagios user : nagios
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change CentCore Macro OK
Copy CentCore in binary directory OK
Change right : /var/run/centreon OK
Change right : /var/lib/centreon OK
Replace CentCore init script Macro OK
Do you want me to install CentCore init script ?
[y/n], default to [n]:
> y
CentCore init script installed OK
Do you want me to install CentCore run level ?
[y/n], default to [n]:
> y
Create /etc/centreon/instCentCore.conf OK
------------------------------------------------------------------------
Start CentPlugins Installation
------------------------------------------------------------------------
Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]
>
Path /var/lib/centreon/centplugins OK
Finding Nagios user : nagios
Finding Nagios group : nagios
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for CentPlugins OK
Installing the plugins OK
Change right on centreon.conf OK
CentPlugins is installed
------------------------------------------------------------------------
Start CentPlugins Traps Installation
------------------------------------------------------------------------
Where is your SNMP configuration directory
default to [/etc/snmp]
>
/etc/snmp OK
Where is your SNMPTT binaries directory
default to [/usr/local/centreon/bin/]
>
/usr/local/centreon/bin/ OK
Finding Nagios group : nagios
Finding Apache user : apache
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for CentPluginsTraps OK
Installing the plugins Trap binaries OK
Change macros for snmptrapd.conf OK
Change macros for snmptt.ini OK
Install : snmptrapd.conf OK
Install : snmp.conf OK
Install : snmptt.ini OK
Install : snmptt OK
Install : snmpttconvertmib OK
Generate SNMPTT configuration FAIL
Create /etc/centreon/instCentPlugins.conf OK
###############################################################################
# #
# Go to the URL : #
# to finish the setup #
# #
# Report bugs at #
# #
# Thanks for using Centreon. #
# ----------------------- #
# Contact : infos@centreon.com #
# http:// #
# #
##############################################################################
Nagios/Centreon monitoring Server Server setup Screencopy:
Ubuntu 客户端安装 (remote server installation and setup)
#apt-cache search nagios-nrpe-server nagios-nrpe-plugin
And install above packages if they don’t exist
#sudo apt-get install nagios-nrpe-server nagios-nrpe-plugin
Then, check and edit the nrpe configuration file at /etc/nagios/nrpe.cfg (default location)
Such as
#sudo vi /etc/nagios/nrpe.cfg (in the following)
Append the Nagios server ip in the following
allowed_hosts=127.0.0.1,your-nagios-server-ip
allowed_hosts=127.0.0.1,192.168.10.247,192.168.10.201
Once finishing the edit nrpe.cfg, that nrpe process needs restart, so do the following:
#ps aux | grep nrpe
and find the nrpe process ID and kill it, then restart the nrpe process. Then the new monitoring should be added in our system such as
#kill “nrpe-process-id”
And start nrpe process as
/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
Once finishing the editing the nrpe.cfg do a basic test
As
#check_nrpe –H remote-machibe-IP
Before adding the monitoring variable in our monitoring server, we have to edit the remote client /etc/nagios/nrpe.cfg file (this is a default location and it might change to other location depending on how you install nagios-nrpe-plugin …
#vi /etc/nagios/nrpe.cfg
For some system, there might need to download some packages such as ksh, sysstat or perl
sudo apt-get install ksh
sudo apt-get install sysstat
For perl package go to to search related perl packages
Here are some examples that we add the following command lines for our remote ubuntu server:
command[check_cpu_234]=/usr/local/nagios/libexec/check_cpu_stats.sh -w 70,40,30 -c 90,60,40
command[check_mem_234]=/usr/local/nagios/libexec/check_memory.pl -w 100: -c 2%
command[check_diskio]=/usr/lib/nagios/plugins/contrib/check_diskio --device=/dev/sda1 --critical=30 --warning=50
command[check_tcptraffic]=/usr/lib/nagios/plugins/contrib/check_tcptraffic --warning=20971520 --critical=83886080 --interface=eth0 --speed=10
For more monitoring Tools, please go to to search free monitor tools.
Here for the shell script check_cpu_stats.sh and its command parameter meaning, please go to that script to see its document or use
#man iostat
to see the detail information. In the above check_cpu_stats.sh script input parameter, we take its default as -w 70,40,30 -c 90,60,40. Here w: meaning warning threshold and c: meaning critical threshold. The meaning of above parameters is corresponding to USER, SYSTEM, IOWAIT about which the cpu spends time on each category.
centreon安装失败后的卸载
Java代码
# rm -rf /usr/local/centreon
# rm -rf /etc/centreon
# rm -rf /etc/httpd/conf.d/centreon.conf
# rm -rf /var/lib/centreon
# ./install -i
另外一个卸载脚本
Java代码
echo 'find / -name centreon -type d | grep -v mysql | grep -v samba | xargs rm -rf...'
findall centreon -type d | grep -v mysql | grep -v samba | xargs rm -rf
echo 'locate centreon | grep -v mysql | grep -v samba | xargs rm -rf...'
locate centreon | grep -v mysql | grep -v samba | xargs rm -rf
updatedb
echo "locate centreon's result:"
locate centreon
监控工作主要由nagios完成?再通过ndo2db写入数据库?最后由centreon调用显示出来
启动服务:
/etc/init.d/nrpe restart
/usr/local/nagios/bin/ndo2db -c /etc/nagios/ndo2db.cfg
/etc/init.d/httpd restart
/etc/init.d/nagios restart
/etc/init.d/centcore restart
/etc/init.d/centstorage restart
Centreon汉化
1.下载语言文件 # wget
2.创建语言目录 # mkdir -p /usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
3.移劢下载的messages.mo至第2步创建的目录 # mv messages.mo /usr/local/centreon/www/locale/zh_CN/LC_MESSAGES/
4.登录centreon?点击administartors?再点option?迚入”my account”?更改语言为zh_CN保存即可。
Nagios插件目录:/usr/lib64/nagios/plugins
配置文件目录:/etc/nagios/objects
被监控端nrpe目录:/etc/nagios
被监控端插件目录:/usr/lib64/nagios/plugins
/usr/local/nagios/libexec/check_nrpe -H 192.168.18.181 -c check_users
为10.201添加监控ping命令步骤
1、 下载监控脚本
cd /usr/lib64/nagios/plugins(监控端和被监控端都要有此脚本)
wget
chown nagios:nagios check_ping
chmod +x check_ping
2、 添加主机
(检测命令要选中check_host_alive,否则会显示主机为down)
3、 定义命令
4、 增加服务
增加check_ping 服务
generic-service为服务模板,以后配置基本都要用到它。
5、 关联主机
配置——服务——关系
6、 被监控端定义command字段
在被监控端,编辑:vim /etc/nagios/nrpe.cfg,添加command字段
被监控端重启nrpe服务
ps aux | grep nrpe
kill 32162
/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg –d
在被监控端测试脚本
在监控机上远程测试
(注意:写command字段和测试时,参数要写正确)
7、 激活配置,重启服务
8、 查看监控内容
参考:
出现问题:
1、CHECK_NRPE: Socket timeout after 10 seconds.
解决方法:
测试NRPE daemon
netstat -ln |grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
修改防火墙规则,开放tcp 5666端口