Skip to content

hosts.cfg

Sander Botman edited this page May 22, 2015 · 5 revisions

This file contains the nagios configuration for all hosts. To create hosts, you can use the nagios_host provider within your recipes.
Example:

nagios_host 'default-host' do
  options 'name'                         => 'default-host',
          'notifications_enabled'        => 1,
          'event_handler_enabled'        => 1,
          'flap_detection_enabled'       => nagios_boolean(nagios_attr(:default_host)[:flap_detection]),
          'process_perf_data'            => nagios_boolean(nagios_attr(:default_host)[:process_perf_data]),
          'retain_status_information'    => 1,
          'retain_nonstatus_information' => 1,
          'notification_period'          => '24x7',
          'register'                     => 0,
          'action_url'                   => nagios_attr(:default_host)[:action_url]
end

To create hosts as objects, you call the create method on the class.
Example:

obj = Nagios::Host.create('default-host')
obj.name = 'default-host'
obj.notifications_enabled = 1
obj.event_handler_enabled = 1
obj.flap_detection_enabled = nagios_boolean(nagios_attr(:default_host)[:flap_detection])
etc...

Configurable items are:

alias
display_name <provider name>
use
address
parents
hostgroups
check_command
initial_state
max_check_attempts
check_interval
retry_interval
active_checks_enabled
passive_checks_enabled
check_period
obsess_over_host
check_freshness
freshness_threshold
event_handler
event_handler_enabled
low_flap_threshold
high_flap_threshold
flap_detection_enabled
flap_detection_options
process_perf_data
retain_status_information
retain_nonstatus_information
contacts
contact_groups
notification_interval
first_notification_delay
notification_period
notification_options
notifications_enabled
stalking_options
notes
notes_url
action_url
icon_image
icon_image_alt
vrml_image
statusmap_image
2d_coords
3d_coords

More information about hosts can be found here

By using template items, you move the object into the templates.cfg file.
Template items are:

name
register

More information about templates can be found here

You can’t perform that action at this time.