Skip to content

Commit

Permalink
Support for transport pipe configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Klein committed Sep 2, 2014
1 parent e7a60ab commit 5193dbd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
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'],
}

}

0 comments on commit 5193dbd

Please sign in to comment.