Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Add notification_period by copying check_period
Browse files Browse the repository at this point in the history
  • Loading branch information
petergphillips committed Feb 22, 2017
1 parent d92dc84 commit c7c40ca
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ Above LWRP resource will create `Host` objects for a chef environment nodes for
- *check_command* (optional, String) - icinga `Host` object attribute `check_command`
- *max_check_attempts* (optional, Integer) - icinga `Host` object attribute `max_check_attempts`
- *check_period* (optional, String) - icinga `Host` object attribute `check_period`
- *notification_period* (optional, String) - icinga `Host` object attribute `notification_period`
- *check_interval* (optional, String/Integer) - icinga `Host` object attribute `check_interval`
- *retry_interval* (optional, Integer) - icinga `Host` object attribute `retry_interval`
- *enable_notifications* (optional, TrueClass/FalseClass) - icinga `Host` object attribute `enable_notifications`
Expand Down Expand Up @@ -855,6 +856,7 @@ Above LWRP resource will create an icinga `Host` template - `generic-host`.
- *check_command* (optional, String) - icinga `Host` object attribute `check_command`
- *max_check_attempts* (optional, Integer) - icinga `Host` object attribute `max_check_attempts`
- *check_period* (optional, String) - icinga `Host` object attribute `check_period`
- *notification_period* (optional, String) - icinga `Host` object attribute `notification_period`
- *check_interval* (optional, String/Integer) - icinga `Host` object attribute `check_interval`
- *retry_interval* (optional, String/Integer) - icinga `Host` object attribute `retry_interval`
- *enable_notifications* (optional, TrueClass/FalseClass) - icinga `Host` object attribute `enable_notifications`
Expand Down Expand Up @@ -946,6 +948,7 @@ Above LWRP resource will create an icinga `Service` template object for a `gener
- *check_command* (optional) - icinga `Service` object attribute `check_command`
- *max_check_attempts* (optional) - icinga `Service` object attribute `max_check_attempts`
- *check_period* (optional) - icinga `Service` object attribute `check_period`
- *notification_period* (optional) - icinga `Service` object attribute `notification_period`
- *check_interval* (optional) - icinga `Service` object attribute `check_interval`
- *retry_interval* (optional) - icinga `Service` object attribute `retry_interval`
- *enable_notifications* (optional, TrueClass/FalseClass) - icinga `Service` object attribute `enable_notifications`
Expand Down Expand Up @@ -1019,6 +1022,7 @@ Above LWRP resource will apply an icinga `Service` object with a Service for set
- *check_command* (optional, String) - icinga `Service` object attribute `check_command`
- *max_check_attempts* (optional, Integer) - icinga `Service` object attribute `max_check_attempts`
- *check_period* (optional, String) - icinga `Service` object attribute `check_period`
- *notification_period* (optional, String) - icinga `Service` object attribute `notification_period`
- *check_interval* (optional, String/Integer) - icinga `Service` object attribute `check_interval`
- *retry_interval* (optional, String/Integer) - icinga `Service` object attribute `retry_interval`
- *enable_notifications* (optional, TrueClass/FalseClass) - icinga `Service` object attribute `enable_notifications`
Expand Down Expand Up @@ -2072,6 +2076,8 @@ Above LWRP resource will apply `Dependency` to all `Host` objects for provided `

* `default['icinga2']['server']['object']['host']['check_period']` (default: `nil`)

* `default['icinga2']['server']['object']['host']['notification_period']` (default: `nil`)

* `default['icinga2']['server']['object']['host']['check_interval']` (default: `1800`)

* `default['icinga2']['server']['object']['host']['retry_interval']` (default: `60`)
Expand Down
1 change: 1 addition & 0 deletions attributes/server_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
default['icinga2']['server']['object']['host']['import'] = 'generic-host'
default['icinga2']['server']['object']['host']['max_check_attempts'] = 3
default['icinga2']['server']['object']['host']['check_period'] = nil
default['icinga2']['server']['object']['host']['notification_period'] = nil
default['icinga2']['server']['object']['host']['check_interval'] = '1m'
default['icinga2']['server']['object']['host']['retry_interval'] = '30s'
default['icinga2']['server']['object']['host']['enable_notifications'] = true
Expand Down
1 change: 1 addition & 0 deletions libraries/provider_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def object_template
:check_command => new_resource.check_command,
:max_check_attempts => new_resource.max_check_attempts,
:check_period => new_resource.check_period,
:notification_period => new_resource.notification_period,
:check_interval => new_resource.check_interval,
:retry_interval => new_resource.retry_interval,
:enable_notifications => new_resource.enable_notifications,
Expand Down
10 changes: 9 additions & 1 deletion libraries/resource_applyservice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def check_period(arg = nil)
)
end

def notification_period(arg = nil)
set_or_return(
:notification_period, arg,
:kind_of => String,
:default => nil
)
end

def check_interval(arg = nil)
set_or_return(
:check_interval, arg,
Expand Down Expand Up @@ -276,7 +284,7 @@ def resource_properties(arg = nil)
set_or_return(
:resource_properties, arg,
:kind_of => Array,
:default => %w(import display_name host_name groups check_command max_check_attempts check_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt merge_vars custom_vars assign_where ignore_where set)
:default => %w(import display_name host_name groups check_command max_check_attempts check_period notification_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt merge_vars custom_vars assign_where ignore_where set)
)
end
end
Expand Down
8 changes: 8 additions & 0 deletions libraries/resource_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ def check_period(arg = nil)
)
end

def notification_period(arg = nil)
set_or_return(
:notification_period, arg,
:kind_of => String,
:default => nil
)
end

def check_interval(arg = nil)
set_or_return(
:check_interval, arg,
Expand Down
10 changes: 9 additions & 1 deletion libraries/resource_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ def check_period(arg = nil)
)
end

def notification_period(arg = nil)
set_or_return(
:notification_period, arg,
:kind_of => String,
:default => nil
)
end

def check_interval(arg = nil)
set_or_return(
:check_interval, arg,
Expand Down Expand Up @@ -259,7 +267,7 @@ def resource_properties(arg = nil)
set_or_return(
:resource_properties, arg,
:kind_of => Array,
:default => %w(import display_name address address6 groups check_command max_check_attempts check_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt custom_vars template)
:default => %w(import display_name address address6 groups check_command max_check_attempts check_period notification_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt custom_vars template)
)
end
end
Expand Down
10 changes: 9 additions & 1 deletion libraries/resource_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def check_period(arg = nil)
)
end

def notification_period(arg = nil)
set_or_return(
:notification_period, arg,
:kind_of => String,
:default => nil
)
end

def check_interval(arg = nil)
set_or_return(
:check_interval, arg,
Expand Down Expand Up @@ -251,7 +259,7 @@ def resource_properties(arg = nil)
set_or_return(
:resource_properties, arg,
:kind_of => Array,
:default => %w(import display_name host_name groups check_command max_check_attempts check_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt custom_vars template)
:default => %w(import display_name host_name groups check_command max_check_attempts check_period notification_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt custom_vars template)
)
end
end
Expand Down
3 changes: 3 additions & 0 deletions templates/default/object.applyservice.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ apply Service <%= object.inspect -%><%= " for (#{options['set']})" unless option
<%- if options['check_period'] -%>
check_period = <%= options['check_period'].inspect %>
<%- end -%>
<%- if options['notification_period'] -%>
notification_period = <%= options['notification_period'].inspect %>
<%- end -%>
<%- if options['check_interval'] -%>
check_interval = <%= options['check_interval'] %>
<%- end -%>
Expand Down
3 changes: 3 additions & 0 deletions templates/default/object.environment.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ object Host <%= node_hash['fqdn'].inspect %> {
<%- if @check_period -%>
check_period = <%= @check_period.inspect %>
<%- end -%>
<%- if @notification_period -%>
notification_period = <%= @notification_period.inspect %>
<%- end -%>
<%- if @check_interval -%>
check_interval = <%= @check_interval %>
<%- end -%>
Expand Down
3 changes: 3 additions & 0 deletions templates/default/object.host.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<%- if options['check_period'] -%>
check_period = <%= options['check_period'].inspect %>
<%- end -%>
<%- if options['notification_period'] -%>
notification_period = <%= options['notification_period'].inspect %>
<%- end -%>
<%- if options['check_interval'] -%>
check_interval = <%= options['check_interval'] %>
<%- end -%>
Expand Down
3 changes: 3 additions & 0 deletions templates/default/object.service.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<%- if options['check_period'] -%>
check_period = <%= options['check_period'].inspect %>
<%- end -%>
<%- if options['notification_period'] -%>
notification_period = <%= options['notification_period'].inspect %>
<%- end -%>
<%- if options['check_interval'] -%>
check_interval = <%= options['check_interval'] %>
<%- end -%>
Expand Down

0 comments on commit c7c40ca

Please sign in to comment.