Use NDOUtils to store Nagios monitoring information to MySQL
Use NDOUtils to store Nagios monitoring information to MySQL
1. NDOUtils installation requirements
Nagios
Mysql
Cpan DBI # Not Required
Cpan DBD: mysql # Not Required
2. Associate the mysql header file and Library
An error may occur when no association is performed in config or make.
- Ln-s/opt/mysql/include/*/usr/include/
- Ln-s/opt/mysql/lib/*/usr/lib/
- Echo '/usr/lib'>/etc/ld. so. conf
- Ldconfig-v
3. Install ndoutils
Http://sourceforge.net/project/showfiles.php? Group_id = 26589
- Http://nchc.dl.sourceforge.net/sourceforge/nagios/ndoutils-1.4b7.tar.gz wget-c
- Tar zxvf ndoutils-1.4b7.tar.gz
- Cd ndoutils-1.4b7
- . /Configure -- prefix =/usr/local/nagios -- enable-mysql -- disable-pgsql LDFLAGS =-L/opt/mysql/lib -- with-mysql-inc =/opt/mysql /include/mysql -- with-mysql-lib =/opt/mysql/lib/mysql
* Use the following mysql parameters in config:
- -- With-mysql-inc =/opt/mysql/include -- with-mysql-lib =/opt/mysql/lib
- # Config successful
- # Make Error
* Use the following mysql parameters in config:
- -- With-mysql-inc =/opt/mysql/include/mysql -- with-mysql-lib =/opt/mysql/lib/mysql
- # Config Error
- # Make successfully and generate a file
- # An error occurs when ndo2db is started.
* No LDFLAGS =-L/opt/mysql/lib
- <Del datetime = "2009-05-27T06: 58: 24 + 00: 00"> LDFLAGS =-L/opt/mysql/lib </del>
- # Ndo2db cannot be imported to the database
Related errors
- In file encoded ded from io. c: 10:
- ../Include/config. h: 261: 25: mysql/mysql. h: no such file or directory
- ../Include/config. h: 262: 26: mysql/errmsg. h: no such file or directory
- Make [1]: *** [io. o] Error 1
- Checking for mysql/mysql. h... no
-
- * ** MySQL include file cocould not be located ...**********************
-
- You chose to compile NDBXT with MySQL support, but I was unable
- Locate on your system. If the include file is
- Installed, use the -- with-mysql-inc argument to specify the location
- Of the MySQL include file.
- Make
- Ll./src
Check whether the following files exist.
Ndo2db-2x
Ndo2db-3x
Ndomod-2x.o
Ndomod-3x.o
4. Copy an object
# My Nagios is 3.0.6, so the copy is ndomod-3x.o, ndo2db-3x, if you are 2. X. x please copy ndomod-2x.o, ndo2db-2x
- 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 /*
5. Copy the configuration file
- Cp./config/ndo */usr/local/nagios/etc/
- Chown nagios: nagios/usr/local/nagios/etc /*
6. Create an ndo mysql database and user
- CREATEDATABASE 'nagios 'DEFAULTCHARACTERSETutf8COLLATEutf8 _ general_ci;
- GRANT select, insert, update, deleteONnagios. * TOnagiosndo @ localhostidentifiedby 'password123 ';
- Flush privileges;
7. Import the database structure
Use the db/installdb script
The following support is required:
cpan DBI
cpan DBD::mysql
- Cd./db/
- ./Installdb-u root-p 123456-h localhost-d nagios
Import using commands (in fact, it is the same as using scripts, or you can use phpmyadmin to import)
- /Opt/mysql/bin/mysql-u root-p-D nagios-h localhost <./db/mysql. SQL
Enter Password
59 tables are imported successfully.
8. modify the configuration file
Vi/usr/local/nagios/etc/ndo2db. cfg
- Db_user = nagiosndo
- Db_pass = password123
Vi/usr/local/nagios/etc/nagios. cfg
- # Modify the value of the following parameter to-1 (this is generally the default value ).
- Event_broker_options =-1
- # Copy and paste the following content under # broker_module =.
- # Note that broker_module = and config_file are on one row.
- # Uncomment the line below if you're running Nagios 3.x
- Broker_module =/usr/local/nagios/bin/ndomod-3x.o config_file =/usr/local/nagios/etc/ndomod. cfg
9. Start ndo2db
- /Usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg
-
- Echo 'rm-f/usr/local/nagios/var/ndo. sock '>/etc/rc. local
- Echo '/usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg'>/etc/rc. local
- # Start startup
- Support for the specified database server is either not yet supported, or was not found on your system.
- /Usr/local/nagios/bin/ndo2db-3x: error while loading shared libraries: libmysqlclient. so.16: cannot open shared object file: No such file or directory
If the preceding error occurs, perform step 1.
10. Restart nagios
- /Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
- Service nagios restart
Generally, the installation has been completed. You can go to the database to check whether the record has been added.
11. Check whether the installation is correct.
- Tail-20/usr/local/nagios/var/nagios. log
[2, 1242971625] ndomod: Successfully flushed 80 queued items to data sink.
[2, 1242971625] ndomod: Error writing to data sink! Some output may get lost...
It seems a problem
First change to output to file
# Vi ndomod. cfg
- Instance_name = default
- # Output_type = tcpsocket
- # Output = 127.0.0.1
-
- Output_type = file
- Output =/usr/local/nagios/var/ndo. dat
- Service nagios restart
Check whether there is a/usr/local/nagios/var/ndo. dat file. OK. If the file is found, the first step is to generate the file.
View File Content
- Cd/usr/local/nagios/var/
- Head-30 ndo. dat
-
- HELLO
- PROTOCOL: 2
- AGENT: NDOMOD
- AGENTVERSION: 1.4b7
- STARTTIME: 1243393299
- DISPOSITION: REALTIME
- CONNECTION: FILE
- CONNECTTYPE: INITIAL
- INSTANCENAME: default
- STARTDATADUMP
-
-
- 202:
- 1 = 300
- 2 = 0
- 3 = 0
- 4 = 1243393292.450675
- 73 = 1243393292
- 74 = 262144
- 72 = ndomod: Error writing to data sink! Some output may get lost...
- 999
-
-
-
- 201:
- 1 = 205
- 2 = 0
Use file2sock to try the socket Method
- ../Bin/file2sock-s/usr/local/nagios/var/ndo. dat-d/usr/local/nagios/var/ndo. sock-t unix-p 5668
Error while writing to destination socket: Connection reset by peer
Try tcp
Vi ndo2db. cfg
- # Socket_type = unix
- Socket_type = tcp
Reload ndo2db
- Ps aux | grep ndo2db
- Kill $ pid
- /Usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg
-
- ../Bin/file2sock-s ndo. dat-d localhost-t tcp-p 5668
Error while writing to destination socket: Connection reset by peer
Still not working. Re-compile ndoutils and add LDFLAGS =-L/opt/mysql/lib
- . /Configure -- prefix =/usr/local/nagios -- enable-mysql -- disable-pgsql LDFLAGS =-L/opt/mysql/lib -- with-mysql-inc =/opt/mysql /include/mysql -- with-mysql-lib =/opt/mysql/lib/mysql
- Make
- # After executing the installation process
========================
200912-07 update
Tail/var/log/messages
- Dec 7 14:09:13 localhost nagios: ndomod: Still unable to connect to data sink. 10547 items lost, 5000 queued items to flush.
- Dec 7 14:09:29 localhost nagios: ndomod: Still unable to connect to data sink. 10746 items lost, 5000 queued items to flush.
Mysql cannot be connected. Restart
/Usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg
- Cocould not bind socket: Address already in use
Ps aux | grep ndo2db
No
Check whether the socket file exists. Delete it.
Ll/usr/local/nagios/var/ndo. sock
Rm/usr/local/nagios/var/ndo. sock
Restart
/Usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg
Tail/var/log/messages
- Dec 7 14:09:45 localhost nagios: ndomod: Successfully connected to data sink. 10861 items lost, 5000 queued items to flush.
- Dec 7 14:09:45 localhost nagios: ndomod: Successfully flushed 5000 queued items to data sink.
- Dec 7 14:09:45 localhost ndo2db-3x: Successfully connected to MySQL database
Solution
Network Monitor Nagios Overview
Nagios construction and Configuration
Build a Nagios monitoring platform in the Nginx Environment
Configure the basic Nagios System on RHEL5.3 (using Nagios-3.1.2)
CentOS 5.5 + Nginx + Nagios monitoring and control terminal installation and Configuration Guide
Install Nagios Core for Ubuntu 13.10 Server
Nagios details: click here
Nagios: click here
This article permanently updates the link address: