define service and hostgroup directives

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.
Locked
[email protected]
Posts: 19
Joined: Tue Feb 07, 2012 7:29 am

define service and hostgroup directives

Post by [email protected] »

When setting up a db to hold the nagios cfg files, I noticed that some of the services I had defined used both the hostgroup_name and hostgroups directives, both worked, which led me to look at why both would be available for use with the define service block. :?

The nagios documentation only mentions hostgroup_name, as a valid directive in the define service block.

However, the hostgroup_name directive appears to imply a single entry rather than the possibility of entering multiple hosgroups, whereas the hostgroups directive would appear to be semantically a better alternative as it implies the possibility of more than one entry.

Both appear to work, I have not tested multiple hostgroups in hostgroup_name. :!:

Will the code be left as is, or should I rework my config files to ensure the hostrgroups directive is no longer used :?:

Thanks
Liam
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: define service and hostgroup directives

Post by scottwilkerson »

Actually, the documentation used hostgroups in service definitions
http://nagios.sourceforge.net/docs/3_0/ ... ml#service

hostgroup_name is for use in hostgroup definitions
http://nagios.sourceforge.net/docs/3_0/ ... #hostgroup
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
[email protected]
Posts: 19
Joined: Tue Feb 07, 2012 7:29 am

Re: define service and hostgroup directives

Post by [email protected] »

Hi Scott,

Can you confirm that the correct directive to use is hostgroups for services and hosts blocks?

The definition you pointed me at defines the hostgroup_name as the directive to use and not hostgroups. see valid directives listed from url given below
The description mentions hostgroups, but the list of valid directives does not.

# service directive block from Nagios docs
####################################
define service{
host_name host_name
hostgroup_name hostgroup_name
service_description service_description
display_name display_name
servicegroups servicegroup_names
is_volatile [0/1]
check_command command_name
initial_state [o,w,u,c]
max_check_attempts #
check_interval #
retry_interval #
active_checks_enabled [0/1]
passive_checks_enabled [0/1]
check_period timeperiod_name
obsess_over_service [0/1]
check_freshness [0/1]
freshness_threshold #
event_handler command_name
event_handler_enabled [0/1]
low_flap_threshold #
high_flap_threshold #
flap_detection_enabled [0/1]
flap_detection_options [o,w,c,u]
process_perf_data [0/1]
retain_status_information [0/1]
retain_nonstatus_information [0/1]
notification_interval #
first_notification_delay #
notification_period timeperiod_name
notification_options [w,u,c,r,f,s]
notifications_enabled [0/1]
contacts contacts
contact_groups contact_groups
stalking_options [o,w,u,c]
notes note_string
notes_url url
action_url url
icon_image image_file
icon_image_alt alt_string
}

# description of hostgroup_name in the docs
#######################################
This directive is used to specify the short name(s) of the hostgroup(s) that the service "runs" on or is associated with. Multiple hostgroups should be separated by commas. The hostgroup_name may be used instead of, or in addition to, the host_name directive.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: define service and hostgroup directives

Post by slansing »

In this case you can use either Hostgroups or a Host to be assigned to the service, either would work fine as described.
Locked