# $Id: 768714ebdcfc934b53cdd85b5c3b13a9e7590a1e $

# 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          grid-admins
	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-service
	service_description     Cache for check_ganglia_metric
	is_volatile             0
	check_period            24x7
	#check_interval          1
	max_check_attempts      1
	normal_check_interval   1
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	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
	#hostgroup_name          ganglia
	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
	#hostgroup_name          grid-servers
	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
	#hostgroup_name          grid-servers
	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
	#hostgroup_name          grid-servers
	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
	#hostgroup_name          grid-servers
	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
	#hostgroup_name          grid-servers
	register                0
}
<% end -%>

define service {
	name            generic-ping-service
	use             generic-service
	service_description     PING
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   5
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    c,r
	check_command           check_ping!100.0,20%!500.0,60%
	#hostgroup_name          grid-servers
	register                0
}

define service {
	name            generic-tcp-port-cert-service
	use             generic-service
	service_description     TCP_Cert
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   2
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_tcp_port_cert!443!30
	register                0
}

define service {
	name            generic-ssh-service
	use             generic-service
	service_description     SSH
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   2
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_ssh
	#hostgroup_name          grid-servers
	register                0
}

## HTTP
define service {
	name            generic-http-service
	use             generic-service
	service_description     HTTP
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   2
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_http
	register                0
}

define service {
	name            generic-http-port-service
	use             generic-http-service
	service_description		HTTP_80
	check_command			check_http_port!80
	register                0
}

define service {
	name            generic-https-service
	use             generic-service
	service_description     HTTPS
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   2
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_https
	register                0
}

define service {
	name            generic-https-port-service
	use             generic-https-service
	service_description     HTTPS_443
	check_command           check_https_port!443
	register                0
}

define service {
	name            generic-https-port-cert-service
	use             generic-https-service
	service_description     HTTPS_443_cert
	check_command           check_https_port_cert!443!30
	register                0
}

## MySQL
define service {
	name            generic-mysql-service
	use             generic-service
	service_description     MySQL
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   2
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_mysql
	register                0
}

define service {
	name            generic-mysql-slave-service
	use             generic-service
	service_description     MySQL_Slave
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   2
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_mysql_slave
	register                0
}

define service {
	name            generic-remote-mysql-heartbeat-service
	use             generic-mysql-service
	service_description     MySQL_Heartbeat
	is_volatile             0
	normal_check_interval   1
	check_command           check_remote_mysql_heartbeat
	register                0
}

define service {
	name            generic-ntp-service
	use             generic-service
	service_description     NTP
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   5
	retry_check_interval    3
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_ntp_time
	register                0
}

define service {
	name            generic-ldap-service
	use             generic-service
	service_description     LDAP
	is_volatile             0
	check_period            24x7
	max_check_attempts      3
	normal_check_interval   2
	retry_check_interval    1
	#contact_groups          grid-admins
	notification_interval   240
	notification_period     24x7
	notification_options    w,u,c,r
	check_command           check_ldap!dc=grid,dc=example,dc=com
	register                0
}

###############################################################################
<%
{
  '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
-%>
