Reader small image

You're reading from  Nagios Core Administration Cookbook Second Edition - Second Edition

Product typeBook
Published inFeb 2016
Publisher
ISBN-139781785889332
Edition2nd Edition
Tools
Right arrow
Author (1)
Tom Ryder
Tom Ryder
author image
Tom Ryder

Tom Ryder is a systems administrator living in New Zealand who works for an internet services provider. He loves terminals, text editors, network monitoring and security, Unix and GNU/Linux, shell script, and programming in general. He is also the author of the Nagios Core Administration Cookbook.
Read more about Tom Ryder

Right arrow

Verifying configuration


In this recipe, you'll learn the most basic step in debugging a Nagios Core configuration, which is to verify it. This is a very useful step to take before restarting the Nagios Core server to load an altered configuration because it will warn us about possible problems. This is a good recipe to follow if you're not able to start the Nagios Core server at any point because of configuration problems and instead get output like this:

# /etc/init.d/nagios reload
Running configuration check... CONFIG ERROR!  Check your Nagios configuration.

Getting ready

You should have a working Nagios Core 4.0 or better server running.

How to do it...

We can verify the Nagios Core configuration as follows:

  1. Run the following command, substituting the path to the nagios binary and our primary nagios.cfg configuration file if necessary:

    # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    
  2. If the output is very long, it might be a good idea to pipe it through a pager program, such as less:

    # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg | less
    
  3. Inspect the output and look for warnings and problems. Here's an example of the part of the output we can expect if our configuration is correct:

    If there's a problem of some sort, we might instead see lines like the following, which is just an example of a possible error; here, my configuration is wrong because I neglected to add a contact_name directive for a new contact:

How it works...

The configuration is parsed as though Nagios Core were about to start up, to check that the configuration all makes sense. It will run basic checks, such as looking for syntax errors, and will also check things such as having at least one host and service to monitor. Some of the things it reports are warnings, meaning that they're not necessarily problems, such as hosts not having any services monitored or not reporting to any contacts.

This is the quickest way to get an idea of whether the Nagios Core configuration is sane and will work correctly and whenever, there's trouble restarting the Nagios Core server, it's a good idea to check the output of this command.

There's more...

The program at /usr/local/nagios/bin/nagios is actually the same program that runs the Nagios Core server, but the -v part of the command is a switch for the program that, instead of starting the server, verifies the configuration and shows any problems with it. The second path is to the configuration file with which Nagios Core starts, which in turn imports configuration files for objects such as the contact, host, and service definitions.

See also

  • The Writing debugging information to the Nagios Core log file recipe, Chapter 10, Security and Performance

Previous PageNext Page
You have been reading a chapter from
Nagios Core Administration Cookbook Second Edition - Second Edition
Published in: Feb 2016Publisher: ISBN-13: 9781785889332
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Tom Ryder

Tom Ryder is a systems administrator living in New Zealand who works for an internet services provider. He loves terminals, text editors, network monitoring and security, Unix and GNU/Linux, shell script, and programming in general. He is also the author of the Nagios Core Administration Cookbook.
Read more about Tom Ryder