Skip to content

Commit

Permalink
change gmond erb templates to gracefully handle nil variables
Browse files Browse the repository at this point in the history
These variables to ganglia::gmond may now safely be undef/nil:

* udp_send_channel
* udp_recv_channel
* tcp_accept_channel
  • Loading branch information
Joshua Hoblitt committed Dec 23, 2013
1 parent 2555891 commit 0c0d598
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
11 changes: 11 additions & 0 deletions spec/system/gmond_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,15 @@ class { 'ganglia::gmond': }
describe service(daemon_name) do
it { should be_running }
end

# default udp_recv_channel
describe port(8649) do
it { should be_listening.with('udp') }
end

# default tcp_accept_channel
describe port(8659) do
it { should be_listening.with('tcp') }
end

end
7 changes: 6 additions & 1 deletion templates/gmond.conf.debian.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ host {

/* Feel free to specify as many udp_send_channels as you like. Gmond
used to only support having a single channel */
<% unless @udp_send_channel.nil? -%>
<% @udp_send_channel.each do |channel| -%>
udp_send_channel {
<%- if channel['mcast_join'] then -%>
Expand All @@ -47,8 +48,10 @@ udp_send_channel {
<%- end -%>
}

<% end -%>
<% end -%>
/* You can specify as many udp_recv_channels as you like as well. */
<% unless @udp_recv_channel.nil? -%>
<% @udp_recv_channel.each do |channel| -%>
udp_recv_channel {
<%- if channel['mcast_join'] then -%>
Expand All @@ -62,9 +65,11 @@ udp_recv_channel {
<%- end -%>
}

<% end -%>
<% end -%>
/* You can specify as many tcp_accept_channels as you like to share
an xml description of the state of the cluster */
<% unless @tcp_accept_channel.nil? -%>
<% @tcp_accept_channel.each do |channel| -%>
tcp_accept_channel {
<%- if channel['port'] then -%>
Expand All @@ -73,7 +78,7 @@ tcp_accept_channel {
}

<% end -%>

<% end -%>
/* Each metrics module that is referenced by gmond must be specified and
loaded. If the module has been statically linked with gmond, it does not
require a load path. However all dynamically loadable modules must include
Expand Down
6 changes: 6 additions & 0 deletions templates/gmond.conf.el5.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ host {

/* Feel free to specify as many udp_send_channels as you like. Gmond
used to only support having a single channel */
<% unless @udp_send_channel.nil? -%>
<% @udp_send_channel.each do |channel| -%>
udp_send_channel {
<%- if channel['mcast_join'] then -%>
Expand All @@ -46,8 +47,10 @@ udp_send_channel {
<%- end -%>
}

<% end -%>
<% end -%>
/* You can specify as many udp_recv_channels as you like as well. */
<% unless @udp_recv_channel.nil? -%>
<% @udp_recv_channel.each do |channel| -%>
udp_recv_channel {
<%- if channel['mcast_join'] then -%>
Expand All @@ -61,16 +64,19 @@ udp_recv_channel {
<%- end -%>
}

<% end -%>
<% end -%>
/* You can specify as many tcp_accept_channels as you like to share
an xml description of the state of the cluster */
<% unless @tcp_accept_channel.nil? -%>
<% @tcp_accept_channel.each do |channel| -%>
tcp_accept_channel {
<%- if channel['port'] then -%>
port = <%= channel['port'] %>
<%- end -%>
}

<% end -%>
<% end -%>
/* The old internal 2.5.x metric array has been replaced by the following
collection_group directives. What follows is the default behavior for
Expand Down
6 changes: 6 additions & 0 deletions templates/gmond.conf.el6.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ host {

/* Feel free to specify as many udp_send_channels as you like. Gmond
used to only support having a single channel */
<% unless @udp_send_channel.nil? -%>
<% @udp_send_channel.each do |channel| -%>
udp_send_channel {
<%- if channel['mcast_join'] then -%>
Expand All @@ -49,8 +50,10 @@ udp_send_channel {
<%- end -%>
}

<% end -%>
<% end -%>
/* You can specify as many udp_recv_channels as you like as well. */
<% unless @udp_recv_channel.nil? -%>
<% @udp_recv_channel.each do |channel| -%>
udp_recv_channel {
<%- if channel['mcast_join'] then -%>
Expand All @@ -64,16 +67,19 @@ udp_recv_channel {
<%- end -%>
}

<% end -%>
<% end -%>
/* You can specify as many tcp_accept_channels as you like to share
an xml description of the state of the cluster */
<% unless @tcp_accept_channel.nil? -%>
<% @tcp_accept_channel.each do |channel| -%>
tcp_accept_channel {
<%- if channel['port'] then -%>
port = <%= channel['port'] %>
<%- end -%>
}

<% end -%>
<% end -%>
/* Each metrics module that is referenced by gmond must be specified and
loaded. If the module has been statically linked with gmond, it does
Expand Down

0 comments on commit 0c0d598

Please sign in to comment.