Use NDOUtils to store Nagios monitoring information to MySQL

Source: Internet
Author: User

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.

  1. Ln-s/opt/mysql/include/*/usr/include/
  2. Ln-s/opt/mysql/lib/*/usr/lib/
  1. Echo '/usr/lib'>/etc/ld. so. conf
  2. Ldconfig-v

3. Install ndoutils

Http://sourceforge.net/project/showfiles.php? Group_id = 26589

  1. Http://nchc.dl.sourceforge.net/sourceforge/nagios/ndoutils-1.4b7.tar.gz wget-c
  2. Tar zxvf ndoutils-1.4b7.tar.gz
  3. Cd ndoutils-1.4b7
  4. . /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:

  1. -- With-mysql-inc =/opt/mysql/include -- with-mysql-lib =/opt/mysql/lib
  2. # Config successful
  3. # Make Error

* Use the following mysql parameters in config:

  1. -- With-mysql-inc =/opt/mysql/include/mysql -- with-mysql-lib =/opt/mysql/lib/mysql
  2. # Config Error
  3. # Make successfully and generate a file
  4. # An error occurs when ndo2db is started.

* No LDFLAGS =-L/opt/mysql/lib

  1. <Del datetime = "2009-05-27T06: 58: 24 + 00: 00"> LDFLAGS =-L/opt/mysql/lib </del>
  2. # Ndo2db cannot be imported to the database

Related errors

  1. In file encoded ded from io. c: 10:
  2. ../Include/config. h: 261: 25: mysql/mysql. h: no such file or directory
  3. ../Include/config. h: 262: 26: mysql/errmsg. h: no such file or directory
  4. Make [1]: *** [io. o] Error 1
  5. Checking for mysql/mysql. h... no
  6.  
  7. * ** MySQL include file cocould not be located ...**********************
  8.  
  9. You chose to compile NDBXT with MySQL support, but I was unable
  10. Locate on your system. If the include file is
  11. Installed, use the -- with-mysql-inc argument to specify the location
  12. Of the MySQL include file.
  1. Make
  2. 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

  1. Cp./src/ndomod-3x.o/usr/local/nagios/bin
  2. Cp./src/ndo2db-3x/usr/local/nagios/bin
  3. Cp./src/log2ndo/usr/local/nagios/bin
  4. Cp./src/file2sock/usr/local/nagios/bin
  5. Chown nagios: nagios/usr/local/nagios/bin /*

5. Copy the configuration file

  1. Cp./config/ndo */usr/local/nagios/etc/
  2. Chown nagios: nagios/usr/local/nagios/etc /*

6. Create an ndo mysql database and user

  1. CREATEDATABASE 'nagios 'DEFAULTCHARACTERSETutf8COLLATEutf8 _ general_ci;
  2. GRANT select, insert, update, deleteONnagios. * TOnagiosndo @ localhostidentifiedby 'password123 ';
  3. Flush privileges;

7. Import the database structure
Use the db/installdb script
The following support is required:

cpan DBI
cpan DBD::mysql

  1. Cd./db/
  2. ./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)

  1. /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

  1. Db_user = nagiosndo
  2. Db_pass = password123

Vi/usr/local/nagios/etc/nagios. cfg

  1. # Modify the value of the following parameter to-1 (this is generally the default value ).
  2. Event_broker_options =-1
  3. # Copy and paste the following content under # broker_module =.
  4. # Note that broker_module = and config_file are on one row.
  5. # Uncomment the line below if you're running Nagios 3.x
  6. Broker_module =/usr/local/nagios/bin/ndomod-3x.o config_file =/usr/local/nagios/etc/ndomod. cfg

9. Start ndo2db

  1. /Usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg
  2.  
  3. Echo 'rm-f/usr/local/nagios/var/ndo. sock '>/etc/rc. local
  4. Echo '/usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg'>/etc/rc. local
  5. # Start startup
  1. Support for the specified database server is either not yet supported, or was not found on your system.
  1. /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

  1. /Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
  2. 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.

  1. 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

  1. Instance_name = default
  2. # Output_type = tcpsocket
  3. # Output = 127.0.0.1
  4.  
  5. Output_type = file
  6. Output =/usr/local/nagios/var/ndo. dat
  1. 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

  1. Cd/usr/local/nagios/var/
  2. Head-30 ndo. dat
  3.  
  4. HELLO
  5. PROTOCOL: 2
  6. AGENT: NDOMOD
  7. AGENTVERSION: 1.4b7
  8. STARTTIME: 1243393299
  9. DISPOSITION: REALTIME
  10. CONNECTION: FILE
  11. CONNECTTYPE: INITIAL
  12. INSTANCENAME: default
  13. STARTDATADUMP
  14.  
  15.  
  16. 202:
  17. 1 = 300
  18. 2 = 0
  19. 3 = 0
  20. 4 = 1243393292.450675
  21. 73 = 1243393292
  22. 74 = 262144
  23. 72 = ndomod: Error writing to data sink! Some output may get lost...
  24. 999
  25.  
  26.  
  27.  
  28. 201:
  29. 1 = 205
  30. 2 = 0

Use file2sock to try the socket Method

  1. ../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

  1. # Socket_type = unix
  2. Socket_type = tcp

Reload ndo2db

  1. Ps aux | grep ndo2db
  2. Kill $ pid
  3. /Usr/local/nagios/bin/ndo2db-3x-c/usr/local/nagios/etc/ndo2db. cfg
  4.  
  5. ../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

  1. . /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
  2. Make
  3. # After executing the installation process

========================
200912-07 update

Tail/var/log/messages

  1. Dec 7 14:09:13 localhost nagios: ndomod: Still unable to connect to data sink. 10547 items lost, 5000 queued items to flush.
  2. 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

  1. 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

  1. Dec 7 14:09:45 localhost nagios: ndomod: Successfully connected to data sink. 10861 items lost, 5000 queued items to flush.
  2. Dec 7 14:09:45 localhost nagios: ndomod: Successfully flushed 5000 queued items to data sink.
  3. 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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.