NDOUTILS Documentation: Last Updated: March 23, 2017
NDOUTILS Documentation: Last Updated: March 23, 2017
NDOUTILS Documentation: Last Updated: March 23, 2017
Version 2.x
CONTENTS
Section Page
1. Introduction ........................................................................................... 3
a) Purpose ............................................................................................ 3
b) Design Overview ............................................................................... 3
c) Instances .......................................................................................... 4
2. Components ......................................................................................... 5
a) Overview ........................................................................................... 5
b) NDOMOD ......................................................................................... 6
c) LOG2NDO ........................................................................................ 7
d) FILE2SOCK ...................................................................................... 7
e) NDO2DB ........................................................................................... 8
4. Installation ............................................................................................ 12
a) Prerequisites ..................................................................................... 12
b) Version Compatability ...................................................................... 12
c) Obtaining New Versions ................................................................... 12
d) Compiling ......................................................................................... 12
e) Installation ........................................................................................ 13
f) Initializing the database .................................................................... 13
g) Configuration .................................................................................... 14
h) Getting things running ...................................................................... 14
Last Updated: March 23, 2017 Page 2 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
1. INTRODUCTION
a) Purpose
The NDOUTILS addon is designed to store all configuration and event data from Nagios in a database. Storing
information from Nagios in a database will allow for quicker retrieval and processing of that data and will help
serve as a foundation for the development of a new PHP-based web interface in Nagios 3.0.
MySQL databases are currently supported by the addon. Support for other database servers may be added if
there is sufficient user interest.
b) Design Overview
The NDOUTILS addon was designed to work for users who have:
Data from each Nagios process (hereafter referred to as "instances") can be stored either in the same database or
different databases than data from other Nagios instances.
Although not yet supported, future development should allow for data from any given Nagios instance to be stored
in multiple databases if desired.
Last Updated: March 23, 2017 Page 3 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
c) Instances
Each Nagios process, whether it is a standalone monitoring server, or part of a distributed, redundant, or failover
monitoring setup, is referred to as an "instance". In order to maintain the integrity of stored data, each Nagios
instance must be labeled with a unique identifier or name.
You can choose the name of each Nagios instance to suit your needs. For instance, you could choose to name
Nagios instances based on their geographical location...
How you name Nagios instances is up to you. The key point to remember is that each and every Nagios process
must have its own unique instance name.
More information on how instance names come into play will be discussed in sections 3 and 4.
Last Updated: March 23, 2017 Page 4 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
2. COMPONENTS
a) Overview
There are four main components that make up the NDO utilities:
Last Updated: March 23, 2017 Page 5 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
The NDO utilities includes a Nagios event broker module (NDOMOD.O) that exports data from the Nagios
daemon.
Assuming that Nagios has been compiled with the event broker enabled (this is the default), you can configure
Nagios to load the NDOMOD module during runtime. Once the module has been loaded by the Nagios daemon, it
can access all of the data and logic present in the running Nagios process.
The NDOMOD module has been designed to export configuration data, as well as information about various
runtime events that occur in the monitoring process, from the Nagios daemon. The module can send this data to a
standard file, a Unix domain socket, or a TCP socket.
The NDOMOD module writes data in a format that the NDO2DB daemon (described later) can understand.
If the NDOMOD module is writing its output to a file, you can configure it to periodically rotate and/or process the
output file using a predefined Nagios command. This can be useful if you want to transfer the output file to
another physical machine (using SSH, etc. ) and send its contents to the NDO2DB daemon using the FILE2SOCK
utility (described later).
If the NDOMOD module is writing it output to a TCP or Unix domain socket, it has some resistance to connection
dropouts. The module will attempt to cache its output until it can (re)connect to the socket for writing. This is
helpful if the process that creates and listens on the socket needs to be restarted, etc.
Last Updated: March 23, 2017 Page 6 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
The LOG2NDO utility has been designed to allow you to import historical Nagios and NetSaint log files into a
database via the NDO2DB daemon (described later). The utility works by sending historical log file data to a
standard file, a Unix domain socket, or a TCP socket in a format the NDO2DB daemon understands. The
NDO2DB daemon can then be used to process that output and store the historical logfile information in a
database.
The FILE2SOCK utility is quite simple. Its reads input from a standard file (or STDIN) and writes all of that data to
either a Unix domain socket or TCP socket. The data that is read is not processed in any way before it is sent to
the socket.
This utility is useful if you are directing the output of the NDOMOD event broker module and/or LOG2NDO utility to
a standard file. Once these components finish writing their output to a file, you can use the FILE2SOCK utility to
send the contents of the file to the NDO2DB daemon's TCP or Unix domain socket.
Last Updated: March 23, 2017 Page 7 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
The NDO2DB utility is designed to take the data output from the NDOMOD and LOG2NDO components and store
it in a MySQL or PostgreSQL database.
When it starts, the NDO2DB daemon creates either a TCP or Unix domain socket and waits for clients to connect.
NDO2DB can run either as a standalone, multi-process daemon or under INETD (if using a TCP socket).
Multiple clients can connect to the NDO2DB daemon's socket and transmit data simultaneously. A seperate
NDO2DB process is spawned to handle each new client that connects. Data is read from each client and stored
in a user-specified database for later retrieval and processing.
Last Updated: March 23, 2017 Page 8 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
3. EXAMPLE CONFIGURATIONS
a) Single Server, Single Instance Setup
The easiest configuration occurs when you have a single Nagios instance running on your network. In this case,
installing and configuring the various components of the NODUTILS addon is fairly straighforward.
The following diagram illustrates how the various components can fit together in a single server, single Nagios
instance setup....
1. The NDOMOD module is configured with an instance name of "default" since there is only one instance of
Nagios that is running on the network.
2. While the Nagios daemon is running and performing its usual business of monitoring the network, the
NDOMOD module is sending configuration data and event information to the TCP or Unix domain socket that
was created by the NDO2DB daemon.
3. The NDO2DB daemon reads data that is coming into the socket from the NDOMOD module.
4. The NDO2DB daemon processes and transforms data that has been received from the NDOMOD module.
5. The processed data is stored in a database for later retrieval and processing.
2. The NDO2DB daemon (which is a seperate process from the Nagios daemon) is running.
Last Updated: March 23, 2017 Page 9 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
Another simple configuration can be used when you have a multiple Nagios instances running on a single server.
Installing and configuring the various components of the NODUTILS addon is similiar as to what was shown in the
previous example.
The following diagram illustrates how the various components can fit together in a single server, multiple Nagios
instance setup....
You'll notice that the diagram above is similiar to the one for the single-server, single instance configuration. The
main difference is that there are now three (3) different Nagios daemons instead of just one.
1. Each Nagios daemon loads the NODMOD module at startup with a unique instance name. In this example the
instances are simply named "nagios1", "nagios2" and "nagios3".
2. Each NDOMOD module sends configuration data and event information for its specific instance of the Nagios
daemon to the TCP or Unix domain socket that was created by the NDO2DB daemon.
6. The NDO2DB daemon reads data that is coming into the socket from the three NDOMOD modules.
7. The NDO2DB daemon processes and transforms data that has been received from the NDOMOD modules.
3. The processed data is stored in a database for later retrieval and processing. Data from each instance of
Nagios is kept seperate (using the instance names as unique identifiers) in the database.
Last Updated: March 23, 2017 Page 10 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
There are two reasons you'll probably want to import your Nagios log files into the same database that Nagios
configuration and event data is stored in:
1. Historical log file data isn't imported into the database by default and having a record of events that occurred
before you implemented the NDOUTILS addon is probably desireable.
2. The NDOMOD module is not able to process realtime log entries from the time right after the Nagios daemon
starts to the time that the NDOMOD module is loaded by the Nagios daemon. This "blackout period" is
unavoidable and causing log entries such as "Nagios 2.0 starting..." to be missed by the NDOMOD module.
Thus, importing day-old Nagios log files on a daily basis (via a cron job) is recommended.
2. The LOG2NDO utility processes the contents of the log files and tags them with an instance name of "default".
This instance name must match the same instance name used by the NDOMOD module in the Nagios
daemon.
3. Historical log file data is sent to the TCP or Unix domain socket in a format that the NDO2DB daemon can
understand.
4. The NDO2DB daemon reads the log file data from the Unix domain socket.
6. Historical log file data is stored in a database for later retrieval and processing. The NDO2DB daemon will
perform some checks to make sure it doesn't re-import duplicate historical log entries, so running the
LOG2NDO utility on the same historical log file multiple times shouldn't have any negative side effects.
Last Updated: March 23, 2017 Page 11 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
4. INSTALLATION
1. Prerequisites
In order to use the NDOUtils addon you'll need to have the following installed and working on your system:
2. Version Compatability
In order to use the NDOUtils addon, you'll need to be running at least Nagios 2.0 (stable). NDOUtils will not work
with beta releases of Nagios 2.0. NDOUtils also works with updates to the Nagios 2.x branch, the Nagios 3.x
branch, and the current branch of Nagios 4.x.
http://www.nagios.org/download/
Updates are always being made to Nagios and NDOUtils, so its important that you stay up to date with the latest
version of NDOUtils that works with the version of Nagios you have.
4. Compiling
Compiling should be easy as pie.
Change to the ndoutils-<version> directory that has been created and run the configure script:
cd ndoutils-2.1.2
./configure
make all
Last Updated: March 23, 2017 Page 12 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
5. Installation
To install the daemon and the ndomod.o NEB module for a Nagios 4.x version, run the following command:
make install
The daemon and the ndomod.o NEB module are also automatically compiled for Nagios versions 2.x and 3.x. To
install when using one of those versions of Nagios, change to the "src" directory:
cd src
make install-2.x
make install-3.x
Note: This assumes that you're running the NDO2DB daemon on the same server that runs Nagios. If you plan
on running the NDO2DB daemon on another machine, you'll need to install the daemon binary on the remote
machine.
NOTE: If you aren't already using it, I would suggest installing phpMyAdmin (http://www.phpmyadmin.net) to help
manage your MySQL server and databases.
1. First, you'll need to create a new database called "nagios", or whatever you'd like.
2. Next, add a user that as SELECT, INSERT, UPDATE, and DELETE privileges on the database you just
created. Keep this information handy, as you'll need it when you configure things.
3. Finally, run the installation script to create the database tables necessary to hold the data the NDO2DB
daemon. The script for doing this (installdb) can be found in the db/ subdirectory of the NDOUtils
distribution.
cd db
./installdb
Install the "ndo2db" daemon by using one of the following two commands, depending if you want it to run as a
standalone, multi-process daemon or under INETD (if using a TCP socket).
make install-init
make install-inetd
The "./configure" process will usually detect the init or inetd type to use, so the install will work properly on most
systems.
Last Updated: March 23, 2017 Page 13 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
7. Configuration
Its time to configure the NDOUtils addon components. Sample config files are included in the config/ subdirectory
of the NDOUtils distribution. Run the following command to install the sample config files:
make install-config
1. First, add the entries from the sample nagios.cfg file (located in the config/ subdirectory) to your main
Nagios configuration file (usually /usr/local/nagios/etc/nagios.cfg).
2. Make sure the following entry appears in your main Nagios configuration file (nagios.cfg). If you don't
specify this option, Nagios may not pass any data to the addon for storage in the database.
event_broker_options=-1
2. Check the system logs and make sure the daemon started up okay
3. Start Nagios if its not running. Note: If Nagios is already running, restart it by sending a SIGHUP signal or
using the Nagios web interface.
4. Check the Nagios logs to make sure it started okay. You should see some log entries that say the
ndomod.o module was loaded successfully and connected to the data sink. If the ndomod.o module didn't
appear to load, check your Nagios config files to make sure you added the appropriate broker module
entries to your main config file. If there are errors connecting to the data sink, make sure the NDO2DB
daemon is running.
5. Check the system logs to make sure the NDO2DB daemon is working okay. You should see some log
entries telling you that a connection was received (by the ndomod.o module loaded by Nagios) and a
connection to the database was successfully make. If there are errors, make sure you specified the
appropriate database, username, password, and table prefix in your ndo2db.cfg config file. If there are
errors relating to being unable to run a specific MySQL query, chances are that you either didn't create the
appropriate database tables (outlined above in the configuration section) or your ndo2db.cfg config file
entries don't match your setup. You'll need to restart the NDO2DB daemon if you make changes to the
config file.
Last Updated: March 23, 2017 Page 14 of 15 Copyright (c) 2005-2017 Ethan Galstad
NDOUTILS Documentation
The database structure for all tables are described in a separate "NDOUtils DB Model" document. It should be
included with the distribution of NDOUtils, so look for it and have fun reading. :-)
Last Updated: March 23, 2017 Page 15 of 15 Copyright (c) 2005-2017 Ethan Galstad