Object Definitions with Multiple Templates

Tata, Joseph jtata at gpworldwide.com
Wed Sep 23 21:08:28 CEST 2009


I believe I've figured this out.  First it turns out my production
Nagios server is running v2.7, I tried it on our test server which is
running 3.0.3 and multiple template definitions work correctly per the
documentation.

Using multiple hostgroups does work as well, I just had to play around
with additive inheritance:

Templates defined:

define host {
use host #This is my "generic" template with all my basic options in it
name prod-host
hostgroups prod_servers #Production server hostgroup (defined elsewhere)
notification_period 24x7
register 0
}
 
define host {
use host
name win-host
hostgroups +win_servers #Windows server host group using additive
inheritance
register 0
}

Define host {
use win-host,prod-host
Address	192.168.1.1
Alias		Production Windows Server
}

This will create a host in both hostgroups as long as I have the
"win-host" template FIRST in the "use" line.  Otherwise the hostgroup
variable from prod-host takes precedence over the additive option and
the host only ends up in "prod_servers".

Thanks for the suggestions.  Hopefully this will help anyone else who
runs into the same problem.

________________________________

From: Mathew Walker [mailto:lmw94002 at hotmail.com] 
Sent: Wednesday, September 23, 2009 12:27 PM
To: Tata, Joseph; nagios-users at lists.sourceforge.net
Subject: RE: [Nagios-users] Object Definitions with Multiple Templates


make sure you have hostgroup definitions setup ...
 
define hostgroup{
        hostgroup_name  DUMMY2
        alias           Dummy2 Servers
}
 
Also NOTE in my test host, I have the line:
use   dummy-hosts1,dummy-hosts2 
 
Each defines group DUMMY1 and DUMMY2 respectively...
 
after restarting Nagios, the host is only a member of the DUMMY2 group.
 
definining options like this the inheritance "overrides" settings with
the values of the subsquent templates listed.  so the group of the last
template listed is the one used.

-- 
Mat W. - http://www.techadre.com <http://www.techadre.com/> 


 
> Date: Wed, 23 Sep 2009 11:05:11 -0400
> From: jtata at gpworldwide.com
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Object Definitions with Multiple Templates
> 
> I am having a problem getting Nagios to accept multiple templates in
> object definitions. 
> 
> Here is an example. I have two templates defined in templates.cfg: 
> 
> 
> define host {
> use host #This is my "generic" template with
> all my basic options in it
> name prod-host
> hostgroups prod_servers #Production server host
> group
> notification_period 24x7
> register 0
> }
> 
> 
> define host {
> use host
> name win-host
> hostgroups win_servers #Windows server host group
> register 0
> }
> 
> Defining an object with either of these templates works fine. However
> what I really need to do is: 
> 
> define host {
> use prod-host,win-host 
> name windows-server
> address 192.1.1.1
> alias My Windows Production Server
> }
> 
> Instead when I run nagios -v I get:
> 
> "Error: Template 'prod-host,win-host' specified in host definition
could
> not be not found" etc.
> 
> http://nagios.sourceforge.net/docs/3_0/objectinheritance.html
indicates
> this should be possible, and that the resulting object should have
> properties of both hosts, but something isn't working. Am I not
> defining something correctly or is this possibly a bug/documentation
> error?
> 
> Thanks
> 
> 
>
------------------------------------------------------------------------
------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart
your
> developing skills, take BlackBerry mobile applications to market and
stay 
> ahead of the curve. Join us from November 9-12, 2009. Register
now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when
reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null


________________________________

Hotmail(r) has ever-growing storage! Don't worry about storage limits.
Check it out.
<http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tu
torial_Storage_062009>  

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list