summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorJohn Ferlito <johnf@inodes.org>2008-12-09 11:46:21 +1100
committerJohn Ferlito <johnf@inodes.org>2008-12-09 11:46:21 +1100
commita0a6d2cfa88cac5418097fb9f71df4cbcae4b192 (patch)
treef1acdbea675b9272cc14f8cb001729dab3060dd1 /lib/puppet
parent68ffd46c9fd87e07d0171e7daa54b951f621c7b7 (diff)
downloadpuppet-a0a6d2cfa88cac5418097fb9f71df4cbcae4b192.tar.gz
puppet-a0a6d2cfa88cac5418097fb9f71df4cbcae4b192.tar.xz
puppet-a0a6d2cfa88cac5418097fb9f71df4cbcae4b192.zip
Add a unique name to objects so we can determine uniqueness when read back in
The nagios object definitions have been updated to correlate with Nagios 3.0.6. In Nagios it is possible to have multiple service checks with the same service_description. eg I could have an check with a service_description of 'SSH' for multiple hosts. So in puppet we can't use it as a unique name for the resource. This patch modifies the code to use $name as the unique name. For some types eg command_name $name ends up in the config and thus we can tell which puppet resources match to which nagios ones. For other types like service there is no direct mapping from $name to a nagios attibute. So we use a custom attribute called _naginator_name. Signed-off-by: John Ferlito <johnf@inodes.org>
Diffstat (limited to 'lib/puppet')
-rwxr-xr-xlib/puppet/external/nagios/base.rb184
-rw-r--r--lib/puppet/type/nagios_hostgroupescalation.rb3
2 files changed, 113 insertions, 74 deletions
diff --git a/lib/puppet/external/nagios/base.rb b/lib/puppet/external/nagios/base.rb
index 25c689559..9b9d7ca34 100755
--- a/lib/puppet/external/nagios/base.rb
+++ b/lib/puppet/external/nagios/base.rb
@@ -196,6 +196,9 @@ class Nagios::Base
args.each { |param,value|
self[param] = value
}
+ if @namevar == :_naginator_name
+ self['_naginator_name'] = self['name']
+ end
end
# Handle parameters like attributes.
@@ -321,115 +324,154 @@ class Nagios::Base
end
# object types
- newtype :command do
- setparameters :command_name, :command_line
+ newtype :host do
+ setparameters :host_name, :alias, :display_name, :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,
+ :failure_prediction_enabled, :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".intern,
+ "3d_coords".intern,
+ :register, :use
+
+ setsuperior "person"
+ map :address => "ipHostNumber"
end
- newtype :contact do
- setparameters :contact_name, :alias, :host_notification_period,
- :host_notification_commands, :service_notification_period,
- :service_notification_commands, :register, :email, :pager,
- :service_notification_options, :host_notification_options
+ newtype :hostgroup do
+ setparameters :hostgroup_name, :alias, :members, :hostgroup_members, :notes,
+ :notes_url, :action_url,
+ :register, :use
+ end
- setsuperior "person"
+ newtype :service do
+ attach :host => :host_name
+ setparameters :host_name, :hostgroup_name, :service_description,
+ :display_name, :servicegroups, :is_volatile, :check_command,
+ :initial_state, :max_check_attempts, :check_interval, :retry_interval,
+ :normal_check_interval, :retry_check_interval, :active_checks_enabled,
+ :passive_checks_enabled, :parallelize_check, :check_period,
+ :obsess_over_service, :check_freshness, :freshness_threshold,
+ :event_handler, :event_handler_enabled, :low_flap_threshold,
+ :high_flap_threshold, :flap_detection_enabled,:flap_detection_options,
+ :process_perf_data, :failure_prediction_enabled, :retain_status_information,
+ :retain_nonstatus_information, :notification_interval,
+ :first_notification_delay, :notification_period, :notification_options,
+ :notifications_enabled, :contacts, :contact_groups, :stalking_options,
+ :notes, :notes_url, :action_url, :icon_image, :icon_image_alt,
+ :register, :use,
+ :_naginator_name
+
+ suppress :host_name
+
+ setnamevar :_naginator_name
end
- newtype :contactgroup do
- setparameters :contactgroup_name, :alias, :members
+ newtype :servicegroup do
+ setparameters :servicegroup_name, :alias, :members, :servicegroup_members,
+ :notes, :notes_url, :action_url,
+ :register, :use
end
- newtype :host do
- setparameters :host_name, :notifications_enabled, :event_handler_enabled,
- :flap_detection_enabled, :process_perf_data, :retain_status_information,
- :retain_nonstatus_information, :register, :use, :alias,
- :address, :check_command, :max_check_attempts, :notification_interval,
- :notification_period, :notification_options, :checks_enabled,
- :failure_prediction_enabled, :parents, :contact_groups
+ newtype :contact do
+ setparameters :contact_name, :alias, :contactgroups,
+ :host_notifications_enabled, :service_notifications_enabled,
+ :host_notification_period, :service_notification_period,
+ :host_notification_options, :service_notification_options,
+ :host_notification_commands, :service_notification_commands,
+ :email, :pager, :address1, :address2, :address3, :address4,
+ :address5, :address6, :can_submit_commands, :retain_status_information,
+ :retain_nonstatus_information,
+ :register, :use
setsuperior "person"
- map :address => "ipHostNumber"
end
- newtype :hostextinfo do
- auxiliary = true
- setparameters :host_name, :notes_url, :icon_image, :icon_image_alt, :vrml_image,
- "2d_coords".intern, "3d_coords".intern
-
- setnamevar :host_name
+ newtype :contactgroup do
+ setparameters :contactgroup_name, :alias, :members, :contactgroup_members,
+ :register, :use
end
- newtype :hostgroup do
- setparameters :hostgroup_name, :alias, :contact_groups, :members
+ # TODO - We should support generic time periods here eg "day 1 - 15"
+ newtype :timeperiod do
+ setparameters :timeperiod_name, :alias, :sunday, :monday, :tuesday,
+ :wednesday, :thursday, :friday, :saturday, :exclude,
+ :register, :use
end
- newtype :hostescalation do
- setparameters :name, :first_notification, :last_notification,
- :notification_interval, :contact_groups,
- :escalation_options, :register, :hostgroup_name
- setnamevar :name
- end
+ newtype :command do
+ setparameters :command_name, :command_line
+ end
- newtype :hostgroupescalation do
+ newtype :servicedependency do
auxiliary = true
- setparameters :hostgroup_name, :first_notification, :last_notification,
- :contact_groups, :notification_interval
+ setparameters :dependent_host_name, :dependent_hostgroup_name,
+ :dependent_service_description, :host_name, :hostgroup_name,
+ :service_description, :inherits_parent, :execution_failure_criteria,
+ :notification_failure_criteria, :dependency_period,
+ :register, :use,
+ :_naginator_name
- setnamevar :hostgroup_name
+ setnamevar :_naginator_name
end
- newtype :service do
- attach :host => :host_name
- setparameters :name, :active_checks_enabled, :passive_checks_enabled,
- :parallelize_check, :obsess_over_service, :check_freshness,
- :notifications_enabled, :event_handler_enabled,
- :flap_detection_enabled, :process_perf_data,
- :retain_status_information, :retain_nonstatus_information, :register,
- :is_volatile, :check_period, :max_check_attempts,
- :normal_check_interval, :retry_check_interval, :contact_groups,
- :notification_interval, :notification_period, :notification_options,
- :service_description, :host_name, :freshness_threshold,
- :check_command, :hostgroup_name, :event_handler, :servicegroups, :host
-
- suppress :host_name
+ newtype :serviceescalation do
+ setparameters :host_name, :hostgroup_name, :service_description, :contacts,
+ :contact_groups, :first_notification, :last_notification,
+ :notification_interval, :escalation_period, :escalation_options,
+ :register, :use,
+ :_naginator_name
- setnamevar :service_description
+ setnamevar :_naginator_name
end
- newtype :servicedependency do
- auxiliary = true
- setparameters :host_name, :service_description, :dependent_host_name,
- :dependent_service_description, :execution_failure_criteria,
- :notification_failure_criteria, :hostgroup_name,
- :dependent_hostgroup_name
+ newtype :hostdependency do
+ auxiliary = true
+ setparameters :dependent_host_name, :dependent_hostgroup_name, :host_name,
+ :hostgroup_name, :inherits_parent, :execution_failure_criteria,
+ :notification_failure_criteria, :dependency_period,
+ :register, :use
- setnamevar :host_name
+ setnamevar :_naginator_name
end
- newtype :serviceescalation do
- setparameters :host_name, :service_description, :first_notification,
- :last_notification, :contact_groups, :notification_interval, :hostgroup_name
+ newtype :hostescalation do
+ setparameters :host_name, :hostgroup_name, :contacts, :contact_groups,
+ :first_notification, :last_notification, :notification_interval,
+ :escalation_period, :escalation_options,
+ :register, :use,
+ :_naginator_name
- setnamevar :host_name
+ setnamevar :_naginator_name
end
- newtype :servicegroup do
- setparameters :servicegroup_name, :alias
+ newtype :hostextinfo do
+ auxiliary = true
+ setparameters :host_name, :notes, :notes_url, :icon_image, :icon_image_alt,
+ :vrml_image, :statusmap_image, "2d_coords".intern, "3d_coords".intern,
+ :register, :use
- setnamevar :servicegroup_name
+ setnamevar :host_name
end
newtype :serviceextinfo do
auxiliary = true
- setparameters :host_name, :service_description, :icon_image, :icon_image_alt
+ setparameters :host_name, :service_description, :notes, :notes_url,
+ :action_url, :icon_image, :icon_image_alt,
+ :register, :use,
+ :_naginator_name
- setnamevar :host_name
+ setnamevar :_naginator_name
end
- newtype :timeperiod do
- setparameters :timeperiod_name, :alias, :sunday, :monday, :tuesday,
- :wednesday, :thursday, :friday, :saturday
- end
end
# $Id$
diff --git a/lib/puppet/type/nagios_hostgroupescalation.rb b/lib/puppet/type/nagios_hostgroupescalation.rb
deleted file mode 100644
index 21b39f681..000000000
--- a/lib/puppet/type/nagios_hostgroupescalation.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'puppet/util/nagios_maker'
-
-Puppet::Util::NagiosMaker.create_nagios_type :hostgroupescalation