Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

Thanks.

share|improve this question

5 Answers 5

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:

cfg_dir=/usr/local/nagios/etc/objects
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 {
  host_name     db01.mydomain.com
  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]+).mydomain.com
}

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

cfg_dir=/etc/nagios/hosts.d
cfg_dir=/etc/nagios/hostgroups.d
use_regexp_matching=1
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.

http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#hostgroup

share|improve this answer

Your Answer

 
discard

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.