Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for transport pipe configuration #238

Merged
merged 1 commit into from
Sep 2, 2014
Merged
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
9 changes: 9 additions & 0 deletions lib/puppet/provider/sensu_handler/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def create
# Optional arguments
self.config = resource[:config] unless resource[:config].nil?
self.exchange = resource[:exchange] unless resource[:exchange].nil?
self.pipe = resource[:pipe] unless resource[:pipe].nil?
self.socket = resource[:socket] unless resource[:socket].nil?
self.handlers = resource[:handlers] unless resource[:handlers].nil?
self.mutator = resource[:mutator] unless resource[:mutator].nil?
Expand Down Expand Up @@ -69,6 +70,14 @@ def exchange=(value)
conf['handlers'][resource[:name]]['exchange'] = value
end

def pipe
conf['handlers'][resource[:name]]['pipe']
end

def pipe=(value)
conf['handlers'][resource[:name]]['pipe'] = value
end

def socket
conf['handlers'][resource[:name]]['socket']
end
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet/type/sensu_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def initialize(*args)
desc "Exchange information used by the amqp type"
end

newproperty(:pipe) do
desc "Pipe information used by the transport type"
end

newproperty(:socket) do
desc "Socket information used by the udp type"

Expand Down
35 changes: 23 additions & 12 deletions manifests/handler.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
# Keys: host, port
# Default: undef
#
# [*pipe*]
# Hash. Pipe information used when type=transport
# Keys: name, type, options
# Default: undef
#
# [*socket*]
# Hash. Socket information when type=tcp or type=udp
# Keys: host, port
Expand Down Expand Up @@ -61,6 +66,7 @@
$handlers = undef,
$severities = ['ok', 'warning', 'critical', 'unknown'],
$exchange = undef,
$pipe = undef,
$mutator = undef,
$socket = undef,
$filters = undef,
Expand Down Expand Up @@ -89,6 +95,10 @@
fail('exchange must be set with type amqp')
}

if $type == 'transport' and !pipe {
fail('pipe must be set with type transport')
}

if $type == 'set' and !$handlers {
fail('handlers must be set with type set')
}
Expand Down Expand Up @@ -129,18 +139,19 @@
}

sensu_handler { $name:
ensure => $ensure,
type => $type,
command => $command_real,
handlers => $handlers,
severities => $severities,
exchange => $exchange,
socket => $socket,
mutator => $mutator,
filters => $filters,
config => $config,
notify => $notify_services,
require => File['/etc/sensu/conf.d/handlers'],
ensure => $ensure,
type => $type,
command => $command_real,
handlers => $handlers,
severities => $severities,
exchange => $exchange,
pipe => $pipe,
socket => $socket,
mutator => $mutator,
filters => $filters,
config => $config,
notify => $notify_services,
require => File['/etc/sensu/conf.d/handlers'],
}

}