Skip to content

Commit cf18b7e

Browse files
Merge pull request #150 from m0dular/SUP-2725-system-collection-freqency
(SUP-2725) Fix system collection frequency
2 parents aaee360 + 6a3cddb commit cf18b7e

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

manifests/system/postgres.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
metrics_command => $metrics_command,
3737
tidy_command => $tidy_command,
3838
metric_ensure => $metrics_ensure,
39-
minute => String($collection_frequency),
39+
minute => "0/${collection_frequency}",
4040
notify => Exec['puppet_metrics_collector_system_daemon_reload'],
4141
}
4242

manifests/system/vmware.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
metrics_command => $metrics_command,
4545
tidy_command => $tidy_command,
4646
metric_ensure => $metrics_ensure,
47-
minute => String($collection_frequency),
47+
minute => "0/${collection_frequency}",
4848
notify => Exec['puppet_metrics_collector_system_daemon_reload'],
4949
}
5050

spec/classes/init_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@
2626

2727
it { is_expected.to compile }
2828
end
29+
30+
context 'when customizing the collection frequency' do
31+
let(:params) { { collection_frequency: 10 } }
32+
33+
['ace', 'bolt', 'orchestrator', 'puppetdb', 'puppetserver'].each do |service|
34+
it { is_expected.to contain_file("/etc/systemd/system/puppet_#{service}-metrics.timer").with_content(%r{OnCalendar=.*0\/10}) }
35+
end
36+
end
2937
end

spec/classes/puppet_metrics_collector_system_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,16 @@ class {'puppet_metrics_collector':
115115

116116
it { is_expected.not_to contain_puppet_metrics_collector__collect('system_cpu').with_metrics_command(%r{--influx-db\s+puppet_metrics}) }
117117
end
118+
119+
context 'when customizing the collection frequency' do
120+
let(:facts) do
121+
{ puppet_metrics_collector: { have_vmware_tools: true, have_systemd: true, have_sysstat: true, have_pe_psql: true },
122+
virtual: 'vmware' }
123+
end
124+
let(:params) { { collection_frequency: 10 } }
125+
126+
['system_cpu', 'system_memory', 'system_processes', 'postgres', 'vmware'].each do |service|
127+
it { is_expected.to contain_file("/etc/systemd/system/puppet_#{service}-metrics.timer").with_content(%r{OnCalendar=.*0\/10}) }
128+
end
129+
end
118130
end

0 commit comments

Comments
 (0)