To kill some possible confusion right form the start, I'm not looking to define me own fields within host definitions, but instead to create a variable that I can use across multiple host definitions to fill in one of the standard fields.
When I add a VM to our Nagios server I add the machines in our virtualisation cluster as the parents of that machine, because if any one of those servers is up, the VM should be accessible. This results in an entry in the definition of each VM of the form:
define host{
host_name xxx1
alias xxx1.domain.tld
address xxx.xxx.xxx.xxx
parents dom0_1, dom0_2, dom0_3, dom0_4, dom0_5, dom0_6
...
}
The thing is, our cluster keeps changing and expanding, and it's a pain in the backside to have to update this entry in every VM, I want to be able to change it in just one place, and have that change affect the definitions for all our VMs.
Nagios calls these "macros", and defines them in resource.cfg, which you'll find in your Nagios installation's /etc directory. Something like:
Added to resource.cfg should do the job ($USER1$ through $USER4$ are already taken); you may have to play about with backslashes and stuff to escape all the commas/spaces, though. Then you can define your hosts like:
Agree with using templates but you need a slight different syntax for templating. A template is a host/service definition with "register 0" added, then you inherit the template in the actual host definition with use, don't forget to inherit the system default-host in your new template
I think you want to use a template: