Use ndoutils to store Nagios monitoring information to MySQL

Source: Internet
Author: User

Environment Introduction:
System: Red Hat Enterprise 5.4
Install and run Nagios correctly. installation directory of version 3.0.6:/usr/local/Nagios
Install and run MySQL correctly. Installation Directory:/usr/local/MySQL
1: Install the DBI package
[Root @ server2 ~] # Cd/usr/local/src/tarbag/
[Root @ server2 tarbag] # wget http://www.cpan.org/modules/by-module/DBI/DBI-1.605.tar.gz
[Root @ server2 tarbag] # tar zxvf DBI-1.605.tar.gz-C ../software/
[Root @ server2 tarbag] # CD ../software/DBI-1.605/
[Root @ server2 DBI-1.605] # Perl makefile. pl
[Root @ server2 DBI-1.605] # Make & make install
2: Install DBD-MySQL
[Root @ server2 DBI-1.605] # cd-
/Usr/local/src/tarbag
[Root @ server2 tarbag] # wget http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-3.0008.tar.gz
[Root @ server2 tarbag] # tar-zxvf DBD-mysql-3.0008.tar.gz-C ../software/
[Root @ server2 tarbag] # CD ../software/DBD-mysql-3.0008/
[Root @ server2 DBD-mysql-3.0008] # unset Lang
[Root @ server2 DBD-mysql-3.0008] # Perl makefile. pl -- libs = "-l/usr/local/MySQL/lib/MySQL-lmysqlclient-L/usr/lib-LZ" -- cflags =-I/usr/local/MySQL/ include/MySQL -- mysql_config =/usr/local/MySQL/bin/mysql_config-testhost = 127.0.0.1 -- testsocket =/tmp/MySQL. sock -- testdb = Nagios -- testuser = root -- testpassword = Password
............................................................... The output is omitted ......................................................
I will use the following settings for compiling and testing:
Cflags (user's choice) =-I/usr/local/MySQL/include/MySQL
Embedded (mysql_config) =
Libs (user's choice) =-L/usr/local/MySQL/lib/MySQL-lmysqlclient-L/usr/lib-LZ
Mysql_config (users choice) =/usr/local/MySQL/bin/mysql_config
Nocatchstderr (default) = 0
Nofoundrows (default) = 0
SSL (guessed) = 0
Testdb (user's choice) = Nagios
Testhost (user's choice) = 127.0.0.1
Testpassword (default) = Password
Testsocket (user's choice) =/tmp/MySQL. Sock
Testuser (user's choice) = root
To change these settings, see 'perl makefile. pl -- help' and
'Perldoc install '.
Using DBI 1.605 (for Perl 5.008008 on i386-linux-thread-multi) installed in/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/
Writing makefile for DBD: MySQL
[Root @ server2 DBD-mysql-3.0008] # Make & make install
3: Create a MySQL header file and a library file link to the/usr directory.
[Root @ server2 DBD-mysql-3.0008] # cd
[Root @ server2 ~] # Ln-S/usr/local/MySQL/include/*/usr/include/
[Root @ server2 ~] # Ln-S/usr/local/MySQL/lib/*/usr/lib/
4: Install ndoutils
[Root @ server2 ~] # Cd/usr/local/src/tarbag/
[Root @ server2 tarbag] # wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b7/ndoutils-1.4b7.tar.gz/download
-- 00:56:40 -- http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b7/ndoutils-1.4b7.tar.gz/download
[Root @ server2 tarbag] # tar-zxvf ndoutils-1.4b7.tar.gz-C ../software/
[Root @ server2 tarbag] # CD ../software/ndoutils-1.4b7/
[Root @ server2 ndoutils-1.4b7] #./configure -- prefix =/usr/local/Nagios -- enable-MySQL
............................................................... The output is omitted ......................................................
MySQL library and include file (s) were found!
Configure: Creating./config. Status
Config. Status: Creating makefile
Config. Status: Creating src/makefile
Config. Status: Creating SUBST
Config. Status: Creating include/config. h
* ** Configuration summary for ndoutils 1.4b7 10-31-2007 ***:
General options:
-------------------------
Ndo2db User: Nagios
Ndo2db group: Nagios
Review the options abve for accuracy. If they look okay,
Type 'make' to compile the Ndo utilities.
[Root @ server2 ndoutils-1.4b7] # Make
[Root @ server2 ndoutils-1.4b7] # cd src/
[Root @ server2 SRC] # cp ndomod-3x.o ndo2db-3x log2ndo file2sock/usr/local/Nagios/bin/
[Root @ server2 SRC] # CD ../DB
[Root @ server2 dB] # MySQL
Welcome to the MySQL monitor. commands end with; or/g.
Your MySQL connection ID is 6
Server version: 5.1.36-log Source Distribution
Type 'help; 'or'/H' for help. type'/C' to clear the current input statement.
Mysql> Create Database Nagios;
Query OK, 1 row affected (0.06 Sec)
[Root @ server2 dB] #./installdb-u root-P password-D Nagios
Install_driver (MySQL) failed: Can't load '/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/MySQL. so 'for module DBD: mysql: libmysqlclient. so.16: cannot open shared object file
The above error occurs because the library file libmysqlclient. so.16 cannot be found. The solution is as follows:
[Root @ server2 dB] # ln-S/usr/local/MySQL/lib/MySQL/libmysqlclient. so.16/usr/lib
[Root @ server2 dB] # ln-S/usr/local/MySQL/lib/MySQL/libmysqlclient. so.16/usr/lib64/(for 64-bit server systems)
[Root @ server2 dB] #./installdb-u root-P 123456-D Nagios
DBD: mysql: DB do failed: Table 'nagios. nagios_dbversion' doesn' t exist at./installdb line 51.
** Creating tables for version 1.4b7
Using mysql. SQL for installation...
** Updating table nagios_dbversion
Done!
DBD: mysql: DB do failed: Table 'nagios. nagios_dbversion' doesn' t exist at./installdb line 51 (this error can be ignored ...)
If the error message "failed: Can't connect to local MySQL server through socket"/var/lib/MySQL. sock '(2). /installdb line 41 "because MySQL cannot be found. sock: The msyql compiled and installed is generally located at/tmp. There are two solutions: Modify/etc/My. the location of sock in the CNF file. The second is to create a soft link under/var/lib/MySQL.
[Root @ server2 dB] # CD ../config
[Root @ server2 config] # cp Ndo */usr/local/Nagios/etc/
Modify the database information of the/usr/local/Nagios/etc/ndo2db. cfg file
[Root @ server2 ~] # Grep-V '^ #'/usr/local/Nagios/etc/ndo2db. cfg | sort | uniq
Db_host = localhost
Db_name = Nagios
Db_pass = Password
DB Port = 3306
Db_prefix = Nagios _
Db_servertype = MySQL
Db_user = root
Debug_file = @ localstatedir @/ndo2db. Debug
Debug_level = 0
Debug_verbosity = 1
Max_debug_file_size = 1000000
Max _eventhandlers_age = 44640
Max_hostchecks_age = 10080
Max_servicechecks_age = 10080
Max_systemcommands_age = 10080
Max_timedevents_age = 1440
Ndo2db_group = Nagios
Ndo2db_user = Nagios
Socket_name =/usr/local/Nagios/var/Ndo. Sock
Socket_type = Unix
Tcp_port = 5668
Modify Nagios. cfg
# Copy the following content and paste it under the/usr/local/Nagios/etc/Nagios. cfg configuration file # broker_module =.
# 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
# Modify the value of the parameters in the/usr/local/Nagios/etc/Nagios. cfg configuration file to-1 (this is the default value ).
[Root @ server2 ~] # Grep 'brok'/usr/local/Nagios/etc/Nagios. cfg | grep-V '^ #'
Event_broker_options =-1
Broker_module =/usr/local/Nagios/bin/ndomod-3x.o config_file =/usr/local/Nagios/etc/ndomod. cfg
# Start ndo2db
/Usr/local/Nagios/bin/ndo2db-3x-C/usr/local/Nagios/etc/ndo2db. cfg
If the message "Support for the specified database server is either not yet supported, or was not found on your system" is displayed, MySQL cannot be found. h. /Specify the header file directory when configure is used!

Solution: ensure the content of the vim/etc/lD. So. conf file.

Include lD. So. conf. d/*. conf

/Usr/local/MySQL/lib/MySQL

/Usr/local/MySQL/include/MySQL

Problem description: cocould not bind socket: address already in use

Solution: Rm/usr/local/Nagios/var/Ndo. Sock
Restart Nagios Service
[Root @ server2 ~] # Service Nagios restart
Running configuration check... done.
Stopping Nagios:. Done.
Starting Nagios: Done.
View logs
[Root @ server2 ~] # Tail-F/usr/local/Nagios/var/Nagios. Log
[2, 1264575689] Caught sigterm, shutting down...
[1264575689] successfully shutdown... (pid = 17653)
[1264575691] Nagios 3.2.0 starting... (pid = 19072)
[1264575691] local time is wed Jan 27 02:01:31 est 2010
[1, 1264575691] log version: 2.0
[1264575691] ndomod: ndomod 1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan galstad (nagios@nagios.org)
[2, 1264575691] ndomod: successfully connected to data sink. 0 queued items to flush.
[1264575691] event broker module '/usr/local/Nagios/bin/ndomod-3x.o' initialized successfully.
[1264575691] finished daemonizing... (new PID = 19075)

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.