当前位置:网站首页>将Nagios监控信息存入MySQL
将Nagios监控信息存入MySQL
2022-06-30 21:55:00 【星哥玩云】
一、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
四、拷贝文件:
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 [email protected] 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" -h192.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
边栏推荐
- 【MySQL入门】第一话 · 初入“数据库”大陆
- 开发属于自己的包
- Error reporting: internal error XFS_ WANT_ CORRUPTED_ GOTO at line 1635 of file fs/xfs/libxfs/xfs_ alloc. c.
- 1-12 preliminary understanding of Express
- 興奮神經遞質——穀氨酸與大腦健康
- 1-7 Path路径模块
- About, Qianxin detects code vulnerabilities and XSS series solves them
- vim 常用快捷键
- 1-13 express监听GET和POST请求&处理请求
- Gartner focuses on low code development in China how UNIPRO practices "differentiation"
猜你喜欢
Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
Rethink healthy diet based on intestinal microbiome
The programmer's girlfriend gave me a fatigue driving test
周少剑,很少见
国产数据库乱象
Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test
机器学习适合女生学吗?
Error filesystemexception: /data/nodes/0/indices/gttxk-hntgkhacm-8n60jw/1/index/ es_ temp_ File: structure needs cleaning
《Dynamic Routing Between Capsules》论文学习总结
Do machine learning jobs require graduate students?
随机推荐
PostgreSQL存储结构浅析
《Dynamic Routing Between Capsules》论文学习总结
Anfulai embedded weekly report no. 270: June 13, 2022 to June 19, 2022
1-14 express托管静态资源
Some problems when SSH default port is not 22
Microservice link risk analysis
1-17 express Middleware
Bloom filter
吴恩达的机器学习适合入门吗?
Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test
盘点华为云GaussDB(for Redis)六大秒级能力
Best wishes for Lao Wu's party
阿婆做的臭豆腐
Modify the name of the launched applet
1-12 preliminary understanding of Express
微服务链路风险分析
1-15 nodemon
在启牛开的股票账户安全吗?如何申请低佣金的股票账户?
Graduation project
1-17 express中间件