Skip to content

Commit e57e47e

Browse files
author
Daniel Rossbach
committed
added sla for notifu
* added custom variable sla in senu_check to use Sensu notification REST API handler * https://github.com/blufor/notifu#readme
1 parent 60096a8 commit e57e47e

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

lib/puppet/provider/sensu_check/json.rb

+9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def create
3232
self.interval = resource[:interval]
3333
self.subscribers = resource[:subscribers]
3434
# Optional arguments
35+
self.sla = resource[:sla] unless resource[:sla].nil?
3536
self.type = resource[:type] unless resource[:type].nil?
3637
self.config = resource[:config] unless resource[:config].nil?
3738
self.aggregate = resource[:aggregate] unless resource[:aggregate].nil?
@@ -105,6 +106,14 @@ def subscribers=(value)
105106
conf['checks'][resource[:name]]['subscribers'] = value
106107
end
107108

109+
def sla
110+
conf['checks'][resource[:name]]['sla'] || []
111+
end
112+
113+
def sla=(value)
114+
conf['checks'][resource[:name]]['sla'] = value
115+
end
116+
108117
def type
109118
conf['checks'][resource[:name]]['type']
110119
end

lib/puppet/type/sensu_check.rb

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def initialize(*args)
6767
desc "Who is subscribed to this check"
6868
end
6969

70+
newproperty(:sla, :array_matching => :all) do
71+
desc "custom variable for notifu"
72+
end
73+
7074
newproperty(:type) do
7175
desc "What type of check is this"
7276
end

manifests/check.pp

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
$standalone = undef,
1414
$interval = '60',
1515
$subscribers = [],
16+
$sla = [],
1617
$notification = undef,
1718
$low_flap_threshold = undef,
1819
$high_flap_threshold = undef,
@@ -34,6 +35,7 @@
3435
handlers => $handlers,
3536
interval => $interval,
3637
subscribers => $subscribers,
38+
sla => $sla,
3739
notification => $notification,
3840
low_flap_threshold => $low_flap_threshold,
3941
high_flap_threshold => $high_flap_threshold,

spec/defines/sensu_check_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
:handlers => ['/handler1', '/handler2'],
2222
:interval => '10',
2323
:subscribers => ['all'],
24+
:sla => ['admin:2'],
2425
:type => 'metric',
2526
:standalone => true,
2627
:notification => 'some text',
@@ -35,6 +36,7 @@
3536
'handlers' => ['/handler1', '/handler2'],
3637
'interval' => '10',
3738
'subscribers' => ['all'],
39+
'sla' => ['admin:2'],
3840
'type' => 'metric',
3941
'standalone' => true,
4042
'notification' => 'some text',

0 commit comments

Comments
 (0)