The Nagios Monitoring数据如何写进Mysql中
下文主要给大家带来The Nagios Monitoring数据如何写进Mysql中,希望这些内容能够带给大家实际用处,这也是我编辑The Nagios Monitoring数据如何写进Mysql中这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。
-------------------------------CMAKE-------------------------------
Install the compiler tool:
#tar xzf cmake-2.8.10.2.tar.gz
#cd cmake-2.8.10.2
#./bootstrap
#make
#make install
-------------------------------Mysql-------------------------------
Preparatory work:
#groupadd mysql
#useradd -r -g mysql mysql
#mkdir /etc/mysql
#chown mysql:mysql /etc/mysql
Compile & Install:
#tar xzf mysql-5.6.10.tar.gz
#cd mysql-5.6.10
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/var/mysql/data \
-DSYSCONFDIR=/etc/mysql \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1
#make
#make install
Database initialization:
#chown -R mysql:mysql /usr/local/mysql
#mkdir -p /var/mysql/data
#chown -R mysql:mysql /var/mysql
#cd /usr/local/mysql/scripts
#./mysql_install_db --user=mysql \
--basedir=/usr/local/mysql \
--datadir=/var/mysql/data \
--skip-name-resolve
#mv ../support-files/my-default.cnf /etc/mysql/my.cnf
#mv ../support-files/mysql.server /etc/rc.d/init.d/mysqld
#service mysqld start
Change Password & verify that the installation was successful:
#/usr/local/mysql/bin/mysqladmin -u root password 'mysql'
#/usr/local/mysql/bin/mysql -uroot -pmysql
>status
-------------------------------Ndoutils-------------------------------
The ndoutils installation:
#tar xzf ndoutils-1.5.2.tar.gz
#cd ndoutils-1.5.2
#./configure --prefix=/usr/local/nagios \
--with-mysql=/usr/local/mysql \
--sysconfdir=/etc/nagios \
--with-ndo2db-user=nagios \
--with-ndo2db-group=nagios \
--enable-mysql
Modify the installation configuration file, otherwise it will make an error:
#vi include/config.h
#Original configuration is as follows:
#include <mysql/mysql.h>
#include <mysql/errmsg.h>
#Modified as follows
#include </usr/local/mysql/include/mysql.h>
#include </usr/local/mysql/include/errmsg.h>
Installation:
#make
Copy the compiled daemon to your Nagios installation:
#cp src/ndomod-3x.o /usr/local/nagios/bin/
#cp src/ndo2db-3x /usr/local/nagios/bin/ndo2db
#chown nagios:nagios /usr/local/nagios/bin/ndo*
Copy the default configuration file to the configuration directory that you specify:
#cp config/ndo2db.cfg-sample /etc/nagios/ndo2db.cfg
#cp config/ndomod.cfg-sample /etc/nagios/ndomod.cfg
#chown nagios:nagios /etc/nagios/ndo*
Increase to start the service:
#cp daemon-init /etc/init.d/ndo2db
#chmod u+x /etc/init.d/ndo2db
Create a database:
#export PATH=$PATH:/usr/local/mysql/bin/
#mysql -uroot -pmysql
>create database nagios;
>quit
Creating a database structure:
#cd db
#mysql -uroot -p nagios<./mysql.sql
Modify the Nagios configuration file:
#vim /etc/nagios/nagios.cfg
#Add by Kingcraft
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/etc/nagios/ndomod.cfg
Empowering for the database user nagios:
#mysql -u root -pmysql
>grant all privileges on nagios.* to 'nagios'@'127.0.0.1' identified by 'nagios';
>quit
Modify the Ndoutils configuration file:
#vim /etc/nagios/ndo2db.cfg
db_user=nagios
db_pass=nagios
db_host=127.0.0.1
#vim /etc/nagios/ndomod.cfg
output=127.0.0.1
Create soft links, or can not start:
#ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64
Verify whether the nagios data can be written to the database:
#service ndo2db start
#service nagios restart
#mysql -u root -pmysql
>use nagios
>select host_id,display_name,address from nagios_hosts;
+---------+-----------------+-----------------+
| host_id | display_name | address |
+---------+-----------------+-----------------+
| 1 | Linuxhost | 192.168.174.130 |
| 2 | linksys-srw224p | 192.168.60.16 |
+---------+-----------------+-----------------+
对于以上关于The Nagios Monitoring数据如何写进Mysql中,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。