Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/puppet/type/sensu_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@
newvalues(/.*/, :absent)
end

newproperty(:scheduler) do
desc "Type of scheduler that schedules the check."
newvalues(:memory, :etcd, :postgres)
end

newproperty(:output_metric_format) do
desc "The metric format generated by the check command."
newvalues(:nagios_perfdata, :graphite_plaintext, :influxdb_line, :opentsdb_line, :prometheus_text, :absent)
Expand Down
5 changes: 5 additions & 0 deletions spec/acceptance/sensu_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
proxy_requests => {
'entity_attributes' => ["entity.Class == 'proxy'"],
},
scheduler => 'memory',
output_metric_format => 'nagios_perfdata',
output_metric_tags => [{'name' => 'instance', 'value' => '{{ .name }}'}],
labels => { 'foo' => 'baz' },
Expand Down Expand Up @@ -76,6 +77,7 @@
expect(data['stdin']).to eq(false)
expect(data['check_hooks']).to eq([{'0' => ['always.sh']},{'1' => ['test.sh']},{'critical' => ['httpd-restart']}])
expect(data['proxy_requests']['entity_attributes']).to eq(["entity.Class == 'proxy'"])
expect(data['scheduler']).to eq('memory')
expect(data['output_metric_format']).to eq('nagios_perfdata')
expect(data['output_metric_tags']).to eq([{'name' => 'instance', 'value' => '{{ .name }}'}])
expect(data['metadata']['labels']['foo']).to eq('baz')
Expand Down Expand Up @@ -162,6 +164,8 @@ class { 'sensu::cli':
proxy_requests => {
'entity_attributes' => ['System.OS==linux'],
},
scheduler => 'etcd',
round_robin => true,
output_metric_format => 'graphite_plaintext',
output_metric_tags => [
{'name' => 'instance', 'value' => '{{ .name }}'},
Expand Down Expand Up @@ -206,6 +210,7 @@ class { 'sensu::cli':
data = JSON.parse(stdout)
expect(data['check_hooks']).to eq([{'critical' => ['httpd-restart']},{'warning' => ['httpd-restart']}])
expect(data['proxy_requests']['entity_attributes']).to eq(['System.OS==linux'])
expect(data['scheduler']).to eq('etcd')
expect(data['output_metric_format']).to eq('graphite_plaintext')
expect(data['output_metric_tags']).to include({'name' => 'instance', 'value' => '{{ .name }}'})
expect(data['output_metric_tags']).to include({'name' => 'prometheus_type', 'value' => 'gauge'})
Expand Down
22 changes: 22 additions & 0 deletions spec/unit/sensu_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,28 @@
end
end

describe 'scheduler' do
[
'memory',
'etcd',
'postgres',
].each do |v|
it "should accept #{v}" do
config[:scheduler] = v
expect(check[:scheduler]).to eq(v.to_sym)
end
end

it 'should not have a default' do
expect(check[:scheduler]).to be_nil
end

it 'should not accept invalid values' do
config[:scheduler] = 'foo'
expect { check }.to raise_error(Puppet::Error, /Invalid value "foo"/)
end
end

describe 'output_metric_format' do
[
'nagios_perfdata',
Expand Down