6

Say I built 1000 servers from the same OS Image, everything is the same including SNMP configs (They all have unique IP addresses of course). For each server, I want to monitor the same 12 services, all via SNMP, using Nagios.

In the Nagios config, is there a way to configure each server such that I don't have to repeat the 12 service entries in every single host file?

Something like: 
    Host MyHost {
      ServiceGroup 12Monkeys;
    }

Better yet, is there a way to say "for these 1000 servers, monitor these 12 services"?

Servicegroup 12Monkeys {
  Servers: 192.168.0.0/24;
}

Thanks!

regulatre
  • 276
  • 3
  • 11

3 Answers3

7

For the services, list a hostgroup_name rather than host_name. Then place each host into the appropriate hostgroup definition.

You can also add exceptions if desired. For example on a service you can list a hostgroup_name and then host_name !server1 to exclude server1 from that service check despite being in the hostgroup.

Documentation on Host Groups is at http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#hostgroup

Jeremy M
  • 819
  • 4
  • 10
  • cool - So I should create a service and in the service definition, specify hosts that offer that service. By using that approach I can specify one or many hosts as offering the service. – regulatre Jul 27 '10 at 19:03
  • Actually I thought that's what you were already doing. This is going a step further. You'd create a hostgroup called 12Monkeys, and list all your servers in it. Then for each of the services, just list `hostgroup_name 12Monkeys` under the service rather than `host_name server1`. One list instead of one for each service. Also like other responses mentioned, you're not stuck with the default files. Nothing is stopping you from generating a 12Monkeys.cfg file out of a management tool, which Nagios will use like the others. My workplace's network group does that with APs/switches for example. – Jeremy M Jul 28 '10 at 23:52
  • Got it. I'm putting together the config now. I'm using vim to build them. – regulatre Jul 29 '10 at 02:32
1

The pointers to use hostgroups and servicegroups are good. If you have a giant datacenter you presumably you have some sort of configuration management / server inventory system. I would also focus on automatically generating the appropriate Nagios configurations for these services from that system.

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
0

Here's a list of some handy tricks using Nagios templates, including monitoring the same services on multiple hosts.

http://nagios.sourceforge.net/docs/3_0/objecttricks.html#service