Created
August 11, 2011 13:19
-
-
Save octplane/1139625 to your computer and use it in GitHub Desktop.
Service template for Nagios in chef.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define host { | |
| use generic-host <%# Inherit default values from a template %> | |
| <%# Use FQDN because munin will send alerts using the FQDN %> | |
| host_name <%= @host['fqdn'] %><%# The name we’re giving to this host %> | |
| alias <%= @host['hostname'] %><%# A longer name associated with the host %> | |
| address <%= @host['ipaddress'] %><%# IP address of the host %> | |
| } | |
| <% @services.each do |service, info| | |
| info = info.to_hash | |
| if DefaultMonitoredValues::check_on(info).include?(@host['swissr']['grid']) | |
| %> | |
| define service { | |
| host <%= @host['fqdn'] %> | |
| <% if DefaultMonitoredValues.passive(info) %> | |
| use passive-service | |
| <% else %> | |
| use generic-service | |
| retry_interval <%= DefaultMonitoredValues::retry_interval(info) %> | |
| max_check_attempts <%= DefaultMonitoredValues::max_check_attempts(info) %> | |
| check_command <%= DefaultMonitoredValues::check_command(info) %> | |
| notification_period <%= DefaultMonitoredValues::notification_period(info)[@host['swissr']['grid']] %> | |
| normal_check_interval <%= DefaultMonitoredValues::normal_check_interval(info) %> | |
| <% end %> | |
| service_description <%= service %> | |
| } | |
| <% info['depends'].each do |parent| | |
| sd, hn = parent.split(/@/) | |
| %> | |
| define servicedependency { | |
| dependent_host_name <%= @host['fqdn'] %> | |
| dependent_service_description <%= service %> | |
| host_name <%= hn %>.<%= @host['domain'] %> | |
| service_description <%= sd %> | |
| inherits_parent 1 | |
| notification_failure_criteria w,u,c | |
| } | |
| <% end | |
| end | |
| end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment