lib/deputy.rb in deputy-0.1.14 vs lib/deputy.rb in deputy-0.1.15
- old
+ new
@@ -11,15 +11,19 @@
class Scout
class Plugin
OPTIONS = {}.to_yaml
+ def self.clean_class_name
+ to_s.split('::')[1..-1].join('::')
+ end
+
protected
def report(metrics)
metrics.each do |key, value|
- Deputy.send_report "#{clean_class_name}.#{key}", value
+ Deputy.send_report "#{self.class.clean_class_name}.#{key}", value
end
end
def error(*args)
report :error => args.map{|a| a.inspect}.join(', ')
@@ -44,17 +48,13 @@
return {} unless File.exist?(memory_file)
YAML.load(File.read(memory_file)) || {}
end
def memory_file
- "/tmp/deputy.memory.#{clean_class_name}.yml"
+ "/tmp/deputy.memory.#{self.class.clean_class_name}.yml"
end
- def clean_class_name
- self.class.to_s.split('::')[1..-1].join('::')
- end
-
# stub options for now...
def option(key)
(YAML.load(self.class::OPTIONS)[key.to_s]||{})['default']
end
end
@@ -87,11 +87,18 @@
def self.run_plugins
content = get("/plugins.rb")
Scout.plugins(content).each do |interval, plugin|
run_every_n_minutes = interval/60
- plugin.new.build_report if START_MINUTE % run_every_n_minutes == 0
+ minutes_to_wait = START_MINUTE % run_every_n_minutes
+ if minutes_to_wait == 0
+ puts "#{plugin.clean_class_name}: running"
+ plugin.new.build_report
+ else
+ puts "#{plugin.clean_class_name}: waiting another #{minutes_to_wait} minutes"
+ end
end
+ send_report 'Deputies', 'finished'
rescue Exception => e
send_report "Deputies.Error", e.message
raise e
end
\ No newline at end of file