Skip to content

Commit

Permalink
Msg reduction filtering. Close: ghoneycutt#102
Browse files Browse the repository at this point in the history
  • Loading branch information
Administrator authored and Administrator committed Apr 28, 2016
1 parent 051b361 commit ebebed4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ Whether a service should be enabled to start at boot. Valid values are true, fal

- *Default*: true

msg_reduction
-------------
Filter duplicated messages. Valid values are true and false.

- *Default*: false

is_log_server
-------------
Boolean to determine if the system syslog service is meant to receive messages from remote hosts.
Expand Down
8 changes: 8 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$daemon = 'USE_DEFAULTS',
$daemon_ensure = 'running',
$daemon_enable = true,
$msg_reduction = false,
$is_log_server = false,
$log_dir = '/srv/logs',
$log_dir_owner = 'root',
Expand Down Expand Up @@ -169,6 +170,13 @@
}
}

if is_string($msg_reduction) == true {
$msg_reduction_bool = str2bool($msg_reduction)
} else {
$msg_reduction_bool = $msg_reduction
}
validate_bool($msg_reduction_bool)

validate_absolute_path($rsyslog_d_dir)
validate_re($daemon_ensure, '^(running|stopped)$', "daemon_ensure may be either 'running' or 'stopped' and is set to <${daemon_ensure}>.")
validate_absolute_path($kernel_target)
Expand Down
10 changes: 10 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,16 @@
end
it { should contain_file('rsyslog_config').with_content(/^\$DirCreateMode 0770$/) }
end

context 'with msg_reduction=true' do
let :params do
{
:msg_reduction => 'true',
}
end
it { should contain_file('rsyslog_config').with_content(/^# Filter duplicated messages$/) }
it { should contain_file('rsyslog_config').with_content(/^\$RepeatedMsgReduction on$/) }
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions templates/rsyslog.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ $template TraditionalFormat,"%timegenerated% %HOSTNAME% %syslogtag%%msg:::drop-l
<% else -%>
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

<% if @msg_reduction_bool.to_s == 'true' -%>
# Filter duplicated messages
$RepeatedMsgReduction on
<% end -%>

# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on
Expand Down

0 comments on commit ebebed4

Please sign in to comment.