用nagios监控linux和windows服务器(六)

 九、使用NDOUtils将Nagios监控信息存入mysql

1.做好Mysql库文件lib和include文件的连接(这点很重要)
ln -s /usr/lib/mysql/* /usr/lib
ln -s /usr/include/mysql/* /usr/include
echo '/usr/lib' >> /etc/ld.so.conf
ldconfig -v
2.创建ndo的mysql 数据库及用户
mysql -u root -p123456
mysql> create database nagios;
mysql> grant select,insert,update,delete on nagios,* to ndouser@localhost identified by 'ndopassword';
mysql> flush privileges;
mysql> exit
3.安装并配置ndoutils
cd /tmp
tar -zxvf ndoutils-1.4b7.tar.gz
cd ndoutils-1.4b7
./configure –enable-mysql
# 执行完成后,注意向上看看打印出的信息,看看是否找到了MySQL的库文件和include文件。
make
cd src/
# 我的Nagios是3.0.5,所以拷贝的是ndomod-3x.o、ndo2db-3x,如果你的是2.X.x请拷贝ndomod-2x.o、ndo2db-2x。
cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/local/nagios/bin
cd ../db
./installdb -u root -p baihe.com -d nagios
#  拷贝配置文件
cd ../config
cp ndo* /usr/local/nagios/etc/
# 修改/usr/local/nagios/etc/ndo2db.cfg文件的数据库信息。
vi /usr/local/nagios/etc/ndo2db.cfg
   db_user=nagiosndo 
   db_pass=password123
# 复制下面内容粘贴到/usr/local/nagios/etc/nagios.cfg配置文件的#broker_module=…下面。
# Uncomment the line below if you’re running Nagios 3.x
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
4.启动ndo2db
/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
#  设置开机启动
echo '/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg' >> /etc/rc.local
5.重新启动nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios restart
6.查看系统日志是否有错误信息
tail -30 /var/log/messages
正确信息如下:
Nov 27 14:09:26 tech nagios: ndomod: NDOMOD 1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan Galstad ([email protected])
Nov 27 14:09:26 tech nagios: ndomod: Successfully connected to data sink. 0 queued items to flush.
Nov 27 14:09:26 tech nagios: Event broker module ‘/usr/local/nagios/bin/ndomod-3x.o’ initialized successfully.
Nov 27 14:09:26 tech nagios: Finished daemonizing… (New PID=18848)
7.查看nagios日志,看是否正常启动
tail -20 /usr/local/nagios/var/nagios.log
正确信息如下:
[1227766166] ndomod: NDOMOD 1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan Galstad ([email protected])
[1227766166] ndomod: Successfully connected to data sink. 0 queued items to flush.
[1227766166] Event broker module ‘/usr/local/nagios/bin/ndomod-3x.o’ initialized successfully.
[1227766166] Finished daemonizing… (New PID=18848)
8.如何用NDOUtils将多个Nagios实例的性能数据写入一个数据库?
配置方法类似于上面的单实例单数据库模式,只是在装第二个实例时省去安装DB一步,并需要修改/usr/local/nagios/etc/ndomod.cfg中的实例名。
实例名默认为instance_name=default,如果有多个实例必需修改成不同的实例名。
如:instance_name=nagios1
注意修改/usr/local/nagios/etc/ndo2db.cfg中数据库连接的相关配置。
 
十、安装使用Nagvis插件
1.安装和配置PHP5
1).安装libxml2
cd /tmp
tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure –prefix=/usr/local/libxml2
make
make install
cp xml2-config /usr/bin
2).安装php5
tar zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/var/lib/mysql --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg6 --with-freetype-dir=/usr/local/freetype --with-zlib --with-png-dir=/usr/local/libpng --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/libgd --enable-ftp --enable-sockets
make
make install
3).配置php
cp php.ini-dict /usr/local/php5/lib/php.ini
vi /usr/local/apache2/conf/httpd.conf
加载php模块,去掉注释,我的版本是缺省就启用的。
LoadModule php5_module modules/libphp5.so
加上下面两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
4).安装zend
tar -zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.3.0a-linux-glibc21-i386
./install
注:安装过程中需要输入php.ini所在的目录
 

你可能感兴趣的:(linux,监控,nagios,nagios配置,nagios安装)