Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: sensu/sensu-puppet
...
head fork: sensu/sensu-puppet
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 02, 2012
@rodjek rodjek Add realname param to sensu_check_config 6eda3f0
@rodjek rodjek Lazy load check config file
Only resource[:name] is set at initialize time, need to load the file after in
order for exists? to work
0ff19d1
@rodjek rodjek Configure a copy of every check configured on a client onto the server 874418c
View
36 lib/puppet/provider/sensu_check_config/json.rb
@@ -4,22 +4,26 @@
def initialize(*args)
super
+ @conf = nil
+ end
+
+ def conf
begin
- @conf = JSON.parse(File.read("/etc/sensu/conf.d/checks_#{resource[:name]}.json"))
+ @conf ||= JSON.parse(File.read("/etc/sensu/conf.d/checks_#{resource[:realname]}.json"))
rescue
- @conf = {}
+ @conf ||= {}
end
end
def flush
- File.open("/etc/sensu/conf.d/checks_#{resource[:name]}.json", 'w') do |f|
- f.puts JSON.pretty_generate(@conf)
+ File.open("/etc/sensu/conf.d/checks_#{resource[:realname]}.json", 'w') do |f|
+ f.puts JSON.pretty_generate(conf)
end
end
def create
- @conf['checks'] = {}
- @conf['checks'][resource[:name]] = {}
+ conf['checks'] = {}
+ conf['checks'][resource[:realname]] = {}
self.handlers = resource[:handlers]
self.command = resource[:command]
self.interval = resource[:interval]
@@ -27,42 +31,42 @@ def create
end
def destroy
- @conf = nil
+ conf = nil
end
def exists?
- @conf.has_key?('checks') and @conf['checks'].has_key?(resource[:name])
+ conf.has_key?('checks') and conf['checks'].has_key?(resource[:realname])
end
def interval
- @conf['checks'][resource[:name]]['interval'].to_s
+ conf['checks'][resource[:realname]]['interval'].to_s
end
def interval=(value)
- @conf['checks'][resource[:name]]['interval'] = value.to_i
+ conf['checks'][resource[:realname]]['interval'] = value.to_i
end
def handlers
- @conf['checks'][resource[:name]]['handlers'] || []
+ conf['checks'][resource[:realname]]['handlers'] || []
end
def handlers=(value)
- @conf['checks'][resource[:name]]['handlers'] = value
+ conf['checks'][resource[:realname]]['handlers'] = value
end
def command
- @conf['checks'][resource[:name]]['command']
+ conf['checks'][resource[:realname]]['command']
end
def command=(value)
- @conf['checks'][resource[:name]]['command'] = value
+ conf['checks'][resource[:realname]]['command'] = value
end
def subscribers
- @conf['checks'][resource[:name]]['subscribers'] || []
+ conf['checks'][resource[:realname]]['subscribers'] || []
end
def subscribers=(value)
- @conf['checks'][resource[:name]]['subscribers'] = value
+ conf['checks'][resource[:realname]]['subscribers'] = value
end
end
View
4 lib/puppet/type/sensu_check_config.rb
@@ -23,6 +23,10 @@ def initialize(*args)
end
newparam(:name) do
+ desc "Some unique name, not the name of the check."
+ end
+
+ newparam(:realname) do
desc "The name of the check"
end
View
9 manifests/check.pp
@@ -5,7 +5,16 @@
$subscribers = []
) {
+ @@sensu_check_config { "${::fqdn}_${name}":
+ realname => $name,
+ command => $command,
+ handlers => $handlers,
+ interval => $interval,
+ subscribers => $subscribers,
+ }
+
sensu_check_config { $name:
+ realname => $name,
command => $command,
handlers => $handlers,
interval => $interval,
View
2  manifests/server.pp
@@ -86,4 +86,6 @@
type => 'pipe',
command => '/etc/sensu/handlers/default',
}
+
+ Sensu_check_config<<| |>>
}

No commit comments for this range

Something went wrong with that request. Please try again.