将Nagios监控信息存入MySQL

发布时间:2020-08-09 23:09:53 作者:wg0411
来源:ITPUB博客 阅读:146
一、NDOUtils安装需求:
Nagios:安装方法:http://www.linuxidc.com/Linux/2014-01/94658.htm 
MySQL:源码安装方法:http://www.linuxidc.com/Linux/2014-04/100758.htm

DBI和DBD-mysql安装方法如下:
shell> perl -MCPAN -e shell 
cpan> install DBI 
cpan> install DBD::mysql

二、关联mysql头文件和库:
不做关联可能在config或make时出错
ln -s /app/mysql/include/* /usr/include/
ln -s /app/mysql/lib/* /usr/lib/
echo '/usr/lib' >> /etc/ld.so.conf
ldconfig -v

三、安装nodutils:
tar zxvf ndoutils-1.4b7.tar.gz
cd ndoutils-1.4b7
./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql LDFLAGS=-L/app/mysql/lib --with-mysql-inc=/app/mysql/include/mysql --with-mysql-lib=/app/mysql/lib/mysql
make && make install

四、拷贝文件:
cp ./src/ndomod-3x.o /usr/local/nagios/bin
cp ./src/ndo2db-3x /usr/local/nagios/bin
cp ./src/log2ndo /usr/local/nagios/bin
cp ./src/file2sock /usr/local/nagios/bin
chown nagios:nagios /usr/local/nagios/bin/*

五、拷贝配置文件:
cp ./config/ndo* /usr/local/nagios/etc/
chown nagios:nagios /usr/local/nagios/etc/*

六、创建ndo的mysql数据库及用户
CREATE DATABASE `nagios` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT select,insert,update,delete ON nagios.* TO nagios@localhost identified by 'nagios';
FLUSH PRIVILEGES ;

七、导入数据库结构
cd ./db/
./installdb -u root -p 123456 -h localhost -d nagios
如果这里root没有密码的话需要进行修改。

八、修改配置文件
vim /usr/local/nagios/etc/ndo2db.cfg

db_user=nagios
db_pass=nagios
socket_type=tcp

vim /usr/local/nagios/etc/nagios.cfg
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg

vim /usr/local/nagios/etc/ndomod.cfg
output_type=file
output=/usr/local/nagios/var/ndo.dat
 
九、启动ndo2db
/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg

十、重启nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 
service nagios restart

十一、检查安装是否正确
tail -f /usr/local/nagios/var/nagios.log

涉及的错误:
启动ndo后在日志中出现:nagios ndo2db-3x: Error: mysql_query() failed for 'INSERT INTO nagios_configfilevariables SET instance_id='1', configfile_id='3', varname='cfg_file', varvalue='/usr/local/nagios//etc/objects/localhost\.cfg 解决办法是使用:mysql -uroot --password="canada" -h292.168.1.97 -e "alter table nagios.nagios_configfilevariables drop key instance_id;alter table nagios.nagios_configfilevariables add index (instance_id, configfile_id, varname); 需要修改表结构。 alter table nagios.nagios_configfilevariables drop key instance_id; alter table nagios.nagios_configfilevariables add index (instance_id, configfile_id, varname);

tcp连接Mysql /usr/local/nagios/bin/file2sock -s /usr/local/nagios/var/ndo.dat -d localhost -t tcp -p 5668
推荐阅读:
  1. nagios 监控自身
  2. nagios监控

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql nagios 信息

上一篇:Finding Trace Files v$diag_info & TKPROF

下一篇:SD-WAN和MPLS孰优孰劣?

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》