September 1, 2014
 
 
RSSRSS feed

Keep Tabs on Network Services with Nagios, Pt. 2

Get to Know Your Configs

  • June 19, 2006
  • By Charlie Schluting

Last week we provided a brief overview of Nagios, and explained how it can make your infrastructure monitoring fun and easy. As promised, we'd like to talk a bit more about the configuration files, because that's the biggest hurdle to setting up a lean, mean monitoring machine with Nagios. Nagios does more than just monitor services, so after some configuration clarifications we'll shift focus to explore the more creative uses of Nagios.

First, it should be noted that Nagat is a Web-based configuration aid for Nagios. It presents a form for you to fill in, and then generates configuration files automagically. Second, make note that you can compile Nagios with Postgres or MySQL support, so the logging ends up in a database for easier parsing by other applications. Now that you're at configuration stage, it's time to take a look at those configuration files in more detail.

The first file of interest is nagios.cfg. This is the main configuration file, and both the Nagios program and Web CGIs use it. Inside, you'll find numerous examples and comments. A frequent point of confusion from new Nagios users seems to be the definition of a "macro." This is simply a variable, of the strange form $VAR$=VALUE. Macros are used in resource files, which are normally used to specify values that you don't wish everyone on the Internet to have access to. Passwords are a good candidate for resource files. To define a resource file, put "resource_file=/path/to/it" in the nagios.cfg file.

Of significant importance are the configuration options related to check scheduling and process management. Nagios will schedule the checks intelligently to avoid forking hundreds of process every minute. Nagios will schedule a check for everything when it starts, but checks will be interleaved to minimize server and client loads. You can minimize the interleaving by adjusting the service_interleave_factor option, if you want to be certain that specifics checks happen at the exact interval you've scheduled them. You can also turn off "smart" scheduling, but if you're monitoring a large number of services on many hosts, you'll be sorry.

Next come the object definitions (or host definitions). This is where you define your hosts and services, as well as groups, contact policies, and many other attributes. A host definition defines the parameters that can be applied to a monitored host, and the service definitions define the attributes of a service. The term "service" in Nagios really means "any monitored attribute," which includes disk space, logged in users, and of course the traditional notion of services (HTTP, POP, etc). There are tons of options, and you really need to configure the alerts to suit your needs. The new method for configuring Nagios is outlined in its documentation under the section about defining object data: using the template-based method. This form of configuration allows far simpler definitions, so anyone just starting out with Nagios should really use that style.

Finally, the CGI configuration file is named cgi.cfg. The CGI configuration defines user access controls, including accounts, passwords and levels of access. These options are well documented, too.

The real key to Nagios is that it's simply a framework. This makes it very easy to produce your own scripts (plugins), or download and use the various ones found throughout the Internet.

Sitemap | Contact Us