溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

將Nagios監(jiān)控信息存入MySQL

發(fā)布時間:2020-08-09 23:09:53 來源:ITPUB博客 閱讀:146 作者:wg0411 欄目:建站服務(wù)器
一、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

二、關(guān)聯(lián)mysql頭文件和庫:
不做關(guān)聯(lián)可能在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/*

六、創(chuàng)建ndo的mysql數(shù)據(jù)庫及用戶
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 ;

七、導(dǎo)入數(shù)據(jù)庫結(jié)構(gòu)
cd ./db/
./installdb -u root -p 123456 -h localhost -d nagios
如果這里root沒有密碼的話需要進(jìn)行修改。

八、修改配置文件
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后在日志中出現(xiàn):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); 需要修改表結(jié)構(gòu)。 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
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI