Page 1 of 1

define service and hostgroup directives

Posted: Wed Mar 27, 2013 4:06 pm
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

Re: define service and hostgroup directives

Posted: Wed Mar 27, 2013 4:53 pm
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

Re: define service and hostgroup directives

Posted: Thu Mar 28, 2013 5:24 am
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.

Re: define service and hostgroup directives

Posted: Thu Mar 28, 2013 11:11 am
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.