Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm already configuring a Nagios setup to monitor about 30 Windows servers. Now i am adding every servers definition to the Windows.cfg file but i think would be easyly configurable to have one .cfg file per server (Server1.cfg, Server2.cfg, Server3.cfg, etc) and link this files from Windows.cfg.

Anyone knows the better way to do this?


share|improve this question
up vote 5 down vote accepted

If your systems are reletively similiar, you should try and use object inheritance to limit the amount of code you have to modify in the future.

In addition to that, you can use the cfg_dir directive in your top-level config (nagios.cfg) to specify an entire directory of configuration files. Any file ending in .cfg will be included, which allows for configuration to be toggled simply be renaming files.

For example:

share|improve this answer
+1 for cfg_dir. A huge win for organization and flexibility. See my answer about hostgroups for another key win. – dmourati Apr 4 '12 at 21:48

What you're describing would work. I usually do something like this. Make config dirs for hosts and hostgroups

mkdir nagios/{hosts.d,hostgroups.d}

Create a file per server

cat nagios/hosts.d/db01.cfg
define host {
  alias         db01
  use           generic-host

Then regex match in the hostgroup

cat nagios/hostgroups.d/db.cfg
define hostgroup {
  hostgroup_name  db
  alias           DB Servers
  members         db([0-9]+)

You'll need to turn on regex in your nagios.cfg and point to the config dirs

share|improve this answer

Well, you can just split up the directives into different files with the cfg extension. Nagios will automatically find them if the are in the config folder. You don't need to put everything in one cfg. You don't even need to link them explicitly.

share|improve this answer

In addition to using the Nagios object inheritance as mentioned you should write a script that automatically adds/deletes the host definitions from data extracted from your configuration management system (AD in Windows-land?). That way Nagios won't get out of date and you don't have to do busy work.

share|improve this answer
+1 on generating host definitions from the configuration management. That's what we're doing using Chef, but that's probably less applicable on the Windows side of the world. – cjc Apr 4 '12 at 22:19

I use hostgroups religiously. By adding machines to a hostgroup and monitoring that serivce on a per-hostgroup basis, adds, moves, and changes are straightforward. I wouldn't dream of running Nagios any other way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.