nagios 安装和配置(含有nrpe结束)所有 (两)

二、ndoutils 安装:

1mysql安装(若未安装)

#apt-get install mysql-servermysql-client



2.DBI安装(若未安装)

#cd /usr/local

# wgethttp://www.cpan.org/modules/by-module/DBI/DBI-1.625.tar.gz
#tar zxvf DBI-1.625.tar.gz
# cd DBI-1.625
# perl Makefile.PL
#make
# make test
# make install

3.DBD安装(若未安装)

#cd/usr/local

# wgethttp://www.cpan.org/modules/by-module/DBD/DBD-mysql-4.023.tar.gz
#tar -zxvf DBD-mysql-4.023.tar.gz
# cd DBD-mysql-4.023
# perlMakefile.PL
假设此时报错。找不到mysql_config ,则先安装 libmysqlclient-dev 。输入以下这行命令:
# apt-get installlibmysqlclient-dev
之后再运行 #perl Makefile.PL
# make
# make install# perl Makefile.PL
4 NDOUtils 安装

#cd /usr/local

#wgethttp://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b7/ndoutils-1.4b7.tar.gz

# tarzxvf ndoutils-1.4b7.tar.gz

# cd ndoutils-1.4b7

#./configure--prefix=/usr/local/nagios --enable-mysql --disable-pgsqlLDFLAGS=-L/opt/mysql/lib --with-mysql-inc=/opt/mysql/include/mysql--with-mysql-lib=/opt/mysql/lib/mysql

# make

复制文件

  1. cp./src/ndomod-3x.o /usr/local/nagios/bin

  2. cp./src/ndo2db-3x /usr/local/nagios/bin

  3. cp./src/log2ndo /usr/local/nagios/bin

  4. cp./src/file2sock /usr/local/nagios/bin

  5. chown nagios:nagios/usr/local/nagios/bin/*

拷贝配置文件

  1. cp./config/ndo* /usr/local/nagios/etc/

  2. chown nagios:nagios/usr/local/nagios/etc/*

5、为NDOUtils创建数据库

#mysql -u root -p
Enterpassword: 这里输入登录password:root
mysql>create database nagios;
mysql> GRANTSELECT,INSERT,UPDATE,DELETE ON nagios.* TO nagios@localhostIDENTIFIED BY '123456';
mysql> flush privileges;
mysql>\q

生成 ndoutils所须要的数据库
#cd db
# ./installdb -u root -p root -h localhost -d nagios
提示Done 。登录mysql 能够看到有59 张表。:
#mysql -u root -p
Enterpassword root
mysql>use nagios
Readingtable information for completion of table and column names
Youcan turn off this feature to get a quicker startup with -A
Databasechanged
mysql>show tables;
59rows in set (0.00 sec) (安装正确)

6、编辑配置文件

选择,插入,更新。删除nagios据库用户权限

# vi/usr/local/nagios/etc/ndo2db.cfg
//安装完毕时提示的数据库的用户和用户组。#代表凝视。
ndo2db_user=nagios
ndo2db_group=nagios
#socket_type=unix
socket_type=tcp
db_user=root // 在前面的 #./installdb -u root -p root -h localhost -d nagios 中指定的
db_pass=root

# vi/usr/local/nagios/etc/nagios.cfg
#
复制以下内容粘贴到 #broker_module...以下。
# 注意 broker_module=config_file是在一行上
broker_module=/usr/local/nagios/bin/ndomod-3x.oconfig_file=/usr/local/nagios/etc/ndomod.cfg
此外。确保 /usr/local/nagios/etc/nagios.cfg中有例如以下行出现。否则,请自行加入
event_broker_options=-1//
Nagios开启 eventbroker


# vi/usr/local/nagios/etc/ndomod.cfg
#output_type=file
output_type=tcpsocket
#output_type=unixsocket
#output=/usr/local/nagios/var/ndo.dat
output=127.0.0.1
#output=/usr/local/nagios/var/ndo.sock
7 、启动ndo2db

启动ndo2db

#/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
假设提示 couldnot bind socket: address already in use 则删除 ndo.sock
rm/usr/local/nagios/var/ndo.sock
设置开机启动()
vim/etc/rc.local
exit0 之前增加下面内容:
/usr/local/nagios/bin/ndo2db-3x-c /usr/local/nagios/etc/ndo2db.cfg
重新启动 ndo2db 的方法:
psaux |grep ndo2db
找到该进程
nagios17539 0.0 0.0 10308 592 ?

Ss 15:52 0:00/usr/local/nagios/bin/ndo2db-3x -c/usr/local/nagios/etc/ndo2db.cfg
nagios 17585 0.6 0.2 19528 1560 ?S 15:52 0:17 /usr/local/nagios/bin/ndo2db-3x -c/usr/local/nagios/etc/ndo2db.cfg
nagios 17586 0.1 0.2 19528 1560 ?S 15:52 0:05 /usr/local/nagios/bin/ndo2db-3x -c/usr/local/nagios/etc/ndo2db.cfg
root 18436 0.0 0.1 4588 800 pts/3S+ 16:39 0:00 grep --color=auto ndo2db

kill pid 号如17539 17585

8.重新启动动nagios

检查配置文件正确性
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重新启动 nagios
#service nagios restart

普通情况下到此已完毕安装,能够去数据库里看下记录有无添加

9、检查安装是否正确

#tail -20 /usr/local/nagios/var/nagios.log

[1227766166] ndomod: NDOMOD1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan Galstad([email protected])

[1227766166]ndomod: Successfully connected to data sink. 0 queued items toflush.

[1227766166] Event broker module‘/usr/local/nagios/bin/ndomod-3x.o’ initializedsuccessfully.

[1227766166] Finished daemonizing… (NewPID=18848)

表示正常。

假设有问题。解决之后,每次都要重新启动ndo2dbnagios

你可能感兴趣的:(nagios)