Group Template & Host Groups

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Group Template & Host Groups

Post by itzik »

Hi,

i have nagios core 4.0.7 installed with Nagiosql and i have issues with enforcing template host on host groups:
- within each host there is an ability to insert template http://www.imageshost.eu/images/2014/08 ... t87b75.jpg this works great though when you have multiple hosts and very convenient if you want to modify the template and then it changes all the hosts template is linked to, the problem start when i want to do another change to multiple hosts, add another template/change parent/ETC then i need to modify 100 and more hosts manually.
- i have created a host group and added all hosts to it and created a host template. http://www.imageshost.eu/images/2014/08 ... e550ee.jpg
- from within the host template i added the host group containing all the hosts.
this is not working and i can`t tell why, am i missing something? can host template be enforced on host group? what is the best practice for such a scenario?

thanks, you have a great product, ;)

itzik vilmovsky
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Group Template & Host Groups

Post by abrist »

I believe adding the hostgroup to the template will just add any host given that template to the hostgroup mentioned in the template config. It will not cause the template settings to be applied to the members of the hostgroup.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

thanks for replying abrist,

so the best practice according to your comment is to add a template to 500 hosts and each and for instance if I would like to add another template to this hosts I need to manually go all over these 500 hosts and add this template to them? or maybe adding the host template another template from its config? i am trying to better understand the "add hosts groups within a host template" feature, is that as you mentioned just for the host group reference or we are missing something and there is some switch i need to trigger either on host or host template which will allow enforcing host templates to host groups to which hosts belong to.

it just make life easier to manage it like that and i am not sure what the developers meant was.

hope someone can enlighten us.

thanks,

itzik vilmvosky
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

anyone? :cry:
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Group Template & Host Groups

Post by Box293 »

Going back to your original question:
itzik wrote:- i have created a host group and added all hosts to it and created a host template. http://www.imageshost.eu/images/2014/08 ... e550ee.jpg
- from within the host template i added the host group containing all the hosts.
this is not working and i can`t tell why, am i missing something? can host template be enforced on host group? what is the best practice for such a scenario?
After adding this new template to your hosts, on each host you need to select the + (additive) radio button under Host groups AND Parents.

What is it that you are trying to achieve with the hosts using host templates? Elaborate with as much detail as possible.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

Hi box,

thanks for replying to my post and trying to assist, my only intention is to create host template and assign it to host group contain multiple hosts, i have tried using additive + sign on hosts and fail each time that is why I sort of gave up, maybe I am doing something wrong if you can elaborate on exactly enforcing it I would be very happy :)
let me give a scenario to simplify and demonstrate why I am facing such a dilemma, I have 200 hosts belong to a host group and a host template contain certain configuration (active checks... parents, ETC) I want the template configuration to be enforced/inherited to the multiple hosts within the host template, why?
- now I have 200 hosts configured to use template from within each host (insert template) and now I need to do a change 60 hosts and change their parent, the reasonable option is to take these 60 hosts add them to host group and create a template containing the appropriate parent and from within the template assign it to host group, does not work for me, even with additive on host template and on hosts, again, maybe I am doing something wrong or inaccurate will be happy if you can elaborate exactly how to do it though I doubt it.
hope that help to better understand, either I am not coherent with the option to add the host template to host groups or something is not configured on my Nagios to support it, anyhow would be very happy to solve it.

thanks,

itzik vilmvosky
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Group Template & Host Groups

Post by Box293 »

itzik wrote:I have 200 hosts belong to a host group and a host template contain certain configuration (active checks... parents, ETC) I want the template configuration to be enforced/inherited to the multiple hosts within the host template,
How do the hosts belong to the hostgroup?
In the host definition using the "hostgroups" directive?
Or
In the host group definition using the "members" directive?

Can you post some configuration files as examples (hosts, hostgroups, templates).
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

Hi,

sorry for the late response i don`t get notification for new posts (need to fix that with configuration)...
the hosts belong to the host groups from within host group definition using the "members" directive
templates.cfg:

Code: Select all

###############################################################################
#
# Host template configuration file
#
# Created by: Nagios QL Version 3.2.0
# Date:       2014-08-19 16:46:52
# Version:    Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios QL will overwite all manual settings during the next update
#
###############################################################################

define host {
        name                            Clusters
        alias                           Linux Cluster Behind Cisco BB 3rd floor
        parents                         Cisco_3rd_floor
        check_command                   check-host-alive
        initial_state                   o
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    24x7
        contact_groups                  admins
        notification_interval           120
        notification_period             24x7
        notification_options            d,u,r
        action_url                      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        icon_image                      rack_linux.png
        statusmap_image                 rack_linux.png
        register                        0
}

define host {
        name                            Clusters-Dell
        alias                           Linux Cluster Behind Dell-Force10 3rd floor
        parents                         Dell_Switch-force10
        check_command                   check-host-alive
        use                             generic-switch
        initial_state                   o
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    24x7
        contact_groups                  admins
        notification_interval           120
        notification_period             24x7
        notification_options            d,u,r
        action_url                      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        icon_image                      rack_linux.png
        statusmap_image                 rack_linux.png
        register                        0
}

define host {
        name                            generic-host
        check_command                   check_ping!100.0,20%!500.0,80%
        max_check_attempts              3
        check_interval                  5
        retry_interval                  1
        check_period                    24x7
        contact_groups                  admins
        notification_interval           120
        notification_period             workhours
        notification_options            d,u,r
        action_url                      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        register                        0
}

define host {
        name                            generic-printer
        check_command                   check-host-alive
        use                             generic-host
        max_check_attempts              10
        check_interval                  5
        retry_interval                  1
        check_period                    24x7
        contact_groups                  admins
        notification_interval           30
        notification_period             workhours
        notification_options            d,r
        statusmap_image                 printer.png
        register                        0
}

define host {
        name                            generic-router
        use                             generic-switch
        initial_state                   o
        max_check_attempts              10
        check_interval                  5
        retry_interval                  1
        active_checks_enabled           1
        check_period                    24x7
        notification_interval           30
        notification_period             24x7
        notification_options            d,r
        action_url                      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        icon_image                      router.gif
        statusmap_image                 router.gd2
        register                        0
}

define host {
        name                            generic-switch
        check_command                   check-host-alive
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    24x7
        contact_groups                  admins
        notification_interval           10
        notification_period             24x7
        notification_options            d,r
        action_url                      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        icon_image                      switch.gif
        statusmap_image                 switch.gd2
        register                        0
}

define host {
        name                            linux-server
        check_command                   check-host-alive
        max_check_attempts              3
        check_interval                  5
        retry_interval                  1
        active_checks_enabled           1
        check_period                    24x7
        check_freshness                 1
        contact_groups                  admins
        notification_interval           120
        notification_period             workhours
        notification_options            d,u,r
        action_url                      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        register                        0
}

define host {
        name                            windows-server
        hostgroups                      windows-servers
        check_command                   check-host-alive
        use                             generic-host
        max_check_attempts              10
        check_interval                  5
        retry_interval                  1
        check_period                    24x7
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            d,r
        register                        0
}

###############################################################################
#
# Host template configuration file
#
# END OF FILE
#
###############################################################################
hosthroups.cfg:

Code: Select all

###############################################################################
#
# Host group configuration file
#
# Created by: Nagios QL Version 3.2.0
# Date:       2014-08-19 16:49:30
# Version:    Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios QL will overwite all manual settings during the next update
#
###############################################################################

define hostgroup {
        hostgroup_name                  Altix-Filer
        alias                           Altix Cluster
        members                         cl-tlv-n1001,cl-tlv-n1002,cl-tlv-n1003,cl-tlv-n1004,cl-tlv-n1005,cl-tlv-n1006,cl-tlv-n1007,cl-tlv-n1008,cl-tlv-n1009,cl-tlv-n1010,cl-tlv-n1011,cl-tlv-n1012,cl-tlv-n1013,cl-tlv-n1014,cl-tlv-n1015,cl-tlv-n1016,cl-tlv-n1017,cl-tlv-n1018,cl-tlv-n1019,cl-tlv-n1020,cl-tlv-n1021,cl-tlv-n1022,cl-tlv-n1023,cl-tlv-n1024,cl-tlv-n1025,cl-tlv-n1026,cl-tlv-n1027,cl-tlv-n1028,cl-tlv-n1029,cl-tlv-n1030,cl-tlv-n1031,cl-tlv-n1032
        register                        1
}

define hostgroup {
        hostgroup_name                  Altix-TLV
        alias                           Altix Cluster
        register                        1
}

define hostgroup {
        hostgroup_name                  Dell-Tlv
        alias                           Dell Cluster
        members                         cl-tlv-n3001,cl-tlv-n3002,cl-tlv-n3003,cl-tlv-n3004,cl-tlv-n3005,cl-tlv-n3006,cl-tlv-n3007,cl-tlv-n3008,cl-tlv-n3009,cl-tlv-n3010,cl-tlv-n3011,cl-tlv-n3012,cl-tlv-n3013,cl-tlv-n3014,cl-tlv-n3015,cl-tlv-n3016,cl-tlv-n3017,cl-tlv-n3018,cl-tlv-n3019,cl-tlv-n3020,cl-tlv-n3021,cl-tlv-n3022,cl-tlv-n3023,cl-tlv-n3024,cl-tlv-n3025,cl-tlv-n3026,cl-tlv-n3027,cl-tlv-n3028,cl-tlv-n3029,cl-tlv-n3030,cl-tlv-n3031,cl-tlv-n3032
        register                        1
}

define hostgroup {
        hostgroup_name                  Icluster
        alias                           ICluster
        members                         cl-tlv-n2001,cl-tlv-n2002,cl-tlv-n2003,cl-tlv-n2004,cl-tlv-n2005,cl-tlv-n2006,cl-tlv-n2007,cl-tlv-n2008,cl-tlv-n2009,cl-tlv-n2010,cl-tlv-n2011,cl-tlv-n2012,cl-tlv-n2013,cl-tlv-n2014,cl-tlv-n2015,cl-tlv-n2016,cl-tlv-n2017,cl-tlv-n2018,cl-tlv-n2019,cl-tlv-n2020,cl-tlv-n2021,cl-tlv-n2022,cl-tlv-n2023,cl-tlv-n2024,cl-tlv-n2025,cl-tlv-n2026,cl-tlv-n2027,cl-tlv-n2028,cl-tlv-n2029,cl-tlv-n2030,cl-tlv-n2031,cl-tlv-n2032
        register                        1
}

define hostgroup {
        hostgroup_name                  linux-servers
        alias                           Linux Servers
        members                         localhost
        register                        1
}

define hostgroup {
        hostgroup_name                  network-printers
        alias                           Network Printers
        register                        1
}

define hostgroup {
        hostgroup_name                  Octane 3
        alias                           Octane 3 Cluster
        members                         cl-tlv-n001,cl-tlv-n002,cl-tlv-n003,cl-tlv-n004,cl-tlv-n005,cl-tlv-n006,cl-tlv-n007,cl-tlv-n008
        register                        1
}

define hostgroup {
        hostgroup_name                  Routers
        alias                           Network Routers
        members                         ISP_CISCO_Router_IL,Router_US
        register                        1
}

define hostgroup {
        hostgroup_name                  switches
        alias                           Network Switches
        members                         cisco_2nd_flr,Cisco_3rd_floor
        register                        1
}

define hostgroup {
        hostgroup_name                  windows-servers
        alias                           Windows Servers
        register                        1
}

###############################################################################
#
# Host group configuration file
#
# END OF FILE
#
###############################################################################
i can`t find any hosts.cfg file hence the nagios.cfg files contains only cfg_dir=/etc/nagiosql/hosts which is a directory. let me know if you need any more information and thanks for replying and trying to help,

itzik vilmovsky
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Group Template & Host Groups

Post by slansing »

Well, you would want to add the template to the hosts, yes, though it should not be hard to go through all 500 if you are using QL, you should be able to shift + select all of them ( could be done in seconds). From looking at the object definitions page in the core docs, I don't believe there is truly an option to assign a single template to an entire hostgroup in the way you think. It has to be done through the template itself:

http://nagios.sourceforge.net/docs/3_0/ ... #hostgroup
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

Hi Slansing,

I just explained a scenario why going through 500 hosts is tedious so saying I need to go all over it is unnecessary, more over, I am not sure with regard to the REAL intention of the option to add host groups within the host templates? what do the writer meant? http://www.imageshost.eu/images/2014/08 ... e550ee.jpg on the right (ignore the red square on the bottom I made mistake :D )
and if its not what the writer meant, what is the best practice to add and manage host template upon host groups?

by the way what is QL you wrote?
looking forward to your reply.

itzik vilmovsky
Locked