# $Id$

# Service templates
<% if node['nagios']['check_ganglia_metric']['enabled'] then -%>
## Ganglia
define service {
	name            generic-ganglia-service
	use             generic-service
	service_description     Ganglia Metric
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   5
	retry_check_interval    1
	contact_groups          <%= node['nagios']['objects']['default_contact_groups'] %>
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	#check_command           check_ganglia_metric!metricName!warning!critical
	register                0
}

<%
ganglia_cache_file = node.value_for_platform_family(
  'debian' => '/var/lib/nagios3/.check_ganglia_metric.cache',
  'rhel'   => '/var/log/nagios/.check_ganglia_metric.cache'
)
-%>
define service {
	name            generic-check_ganglia_cache-service
	use             generic-ganglia-service
	service_description     Cache for check_ganglia_metric
	max_check_attempts      1
	normal_check_interval   1
	retry_check_interval    1
	check_command           check_file_age!<%= ganglia_cache_file %>!90!120
	host_name               localhost
	register                0
}

define service {
	name            generic-ganglia_heartbeat-service
	use             generic-ganglia-service
	service_description     Ganglia gmetad Heartbeat
	max_check_attempts      3
	normal_check_interval   1
	retry_check_interval    1
	check_command           check_ganglia_metric!load_fifteen!10.0!20.0
	register                0
}

define service {
	name            generic-load_one-service
	use             generic-ganglia-service
	service_description	CPU Load 1 Min via Ganglia
	check_command           check_ganglia_metric!load_one!5.0!10.0
	register                0
}

define service {
	name            generic-load_five-service
	use             generic-ganglia-service
	service_description	CPU Load 5 Min via Ganglia
	check_command           check_ganglia_metric!load_five!4.0!6.0
	register                0
}

define service {
	name            generic-load_fifteen-service
	use             generic-ganglia-service
	service_description	CPU Load 15 Min via Ganglia
	check_command           check_ganglia_metric!load_fifteen!3.0!4.0
	register                0
}

define service {
	name            generic-part_max_used-service
	use             generic-ganglia-service
	service_description	Maximum Disk Space Used via Ganglia
	check_command           check_ganglia_metric!part_max_used!80!90
	register                0
}

define service {
	name            generic-proc_total-service
	use             generic-ganglia-service
	service_description	Total Processes via Ganglia
	check_command           check_ganglia_metric!proc_total!250!400
	register                0
}
<% end -%>
<%
{
  'service'           => node['nagios']['objects']['services'],
  'servicegroup'      => node['nagios']['objects']['servicegroups'],
  'servicedependency' => node['nagios']['objects']['servicedependencies'],
  'serviceescalation' => node['nagios']['objects']['serviceescalations'],
  'serviceextinfo'    => node['nagios']['objects']['serviceextinfos']
}.each do |type_name, objects|
  objects.each do |object|
-%>
define <%= type_name %> {
  <% object.each do |key, value| -%>
	<%= key %>	<%= value %>
  <% end -%>
}

<%
  end
end
-%>
