Skip to content

Commit

Permalink
added sla for notifu
Browse files Browse the repository at this point in the history
  * added custom variable sla in senu_check to use Sensu notification REST API handler
  * https://github.com/blufor/notifu#readme
  • Loading branch information
Daniel Rossbach committed May 8, 2013
1 parent 60096a8 commit e57e47e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/puppet/provider/sensu_check/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def create
self.interval = resource[:interval]
self.subscribers = resource[:subscribers]
# Optional arguments
self.sla = resource[:sla] unless resource[:sla].nil?
self.type = resource[:type] unless resource[:type].nil?
self.config = resource[:config] unless resource[:config].nil?
self.aggregate = resource[:aggregate] unless resource[:aggregate].nil?
Expand Down Expand Up @@ -105,6 +106,14 @@ def subscribers=(value)
conf['checks'][resource[:name]]['subscribers'] = value
end

def sla
conf['checks'][resource[:name]]['sla'] || []
end

def sla=(value)
conf['checks'][resource[:name]]['sla'] = value
end

def type
conf['checks'][resource[:name]]['type']
end
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet/type/sensu_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def initialize(*args)
desc "Who is subscribed to this check"
end

newproperty(:sla, :array_matching => :all) do
desc "custom variable for notifu"
end

newproperty(:type) do
desc "What type of check is this"
end
Expand Down
2 changes: 2 additions & 0 deletions manifests/check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$standalone = undef,
$interval = '60',
$subscribers = [],
$sla = [],
$notification = undef,
$low_flap_threshold = undef,
$high_flap_threshold = undef,
Expand All @@ -34,6 +35,7 @@
handlers => $handlers,
interval => $interval,
subscribers => $subscribers,
sla => $sla,
notification => $notification,
low_flap_threshold => $low_flap_threshold,
high_flap_threshold => $high_flap_threshold,
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/sensu_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:handlers => ['/handler1', '/handler2'],
:interval => '10',
:subscribers => ['all'],
:sla => ['admin:2'],
:type => 'metric',
:standalone => true,
:notification => 'some text',
Expand All @@ -35,6 +36,7 @@
'handlers' => ['/handler1', '/handler2'],
'interval' => '10',
'subscribers' => ['all'],
'sla' => ['admin:2'],
'type' => 'metric',
'standalone' => true,
'notification' => 'some text',
Expand Down

0 comments on commit e57e47e

Please sign in to comment.