Skip to content

Commit

Permalink
Merge pull request #435 from fribergr/agent-multiple-alias-support
Browse files Browse the repository at this point in the history
Support multiple zabbix_alias
  • Loading branch information
bastelfreak authored Oct 23, 2017
2 parents e0eccd5 + 29f66e9 commit 6b77f0f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
$buffersend = $zabbix::params::agent_buffersend,
$buffersize = $zabbix::params::agent_buffersize,
$maxlinespersecond = $zabbix::params::agent_maxlinespersecond,
$zabbix_alias = $zabbix::params::agent_zabbix_alias,
Optional[Array] $zabbix_alias = $zabbix::params::agent_zabbix_alias,
$timeout = $zabbix::params::agent_timeout,
$allowroot = $zabbix::params::agent_allowroot,
$zabbix_user = $zabbix::params::agent_zabbix_user,
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,28 @@
it { is_expected.not_to contain_file('/etc/systemd/system/zabbix-agent.service') }
end
end

context 'when declaring zabbix_alias' do
let :params do
{
zabbix_alias: %w[testname]
}
end

it { is_expected.to contain_file(config_path).with_content %r{^Alias=testname$} }
end

context 'when declaring zabbix_alias as array' do
let :params do
{
zabbix_alias: %w[name1 name2]
}
end

it { is_expected.to contain_file(config_path).with_content %r{^Alias=name1$} }
it { is_expected.to contain_file(config_path).with_content %r{^Alias=name2$} }
end

context 'configuration file with full options' do
let :params do
{
Expand Down
6 changes: 5 additions & 1 deletion templates/zabbix_agentd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ MaxLinesPerSecond=<%= @maxlinespersecond %>
# Now shorthand key zabbix.userid may be used to retrieve data.
# Aliases can be used in HostMetadataItem but not in HostnameItem parameters.
#
<% if @zabbix_alias %>Alias=<%= @zabbix_alias %><% end %>
<% if @zabbix_alias %>
<%- @zabbix_alias.each do |zalias| -%>Alias=<%= zalias %>
<%- end -%>
<% end %>


### Option: Timeout
# Spend no more than Timeout seconds on processing
Expand Down

0 comments on commit 6b77f0f

Please sign in to comment.