diff options
author | Anton Aksola <anton.aksola@nebula.fi> | 2015-08-28 11:05:18 +0300 |
---|---|---|
committer | Anton Aksola <anton.aksola@nebula.fi> | 2015-08-28 11:05:18 +0300 |
commit | 0906e02a8538b698ed8bd7c72e6a09d3e809b67a (patch) | |
tree | d494ee43f71d41034efa98f5b5ab59ab5500207a /lib/oxidized/worker.rb | |
parent | 18cf96b36e54cb52c678e4e6395e595b6f9b4159 (diff) |
Initial implementation of the hook feature
The current implementation is modular and allows users to define hooks
in several ways:
* Use one of the built-in hook types (currently only 'exec')
* Define their own Hook classes inside ~/.config/oxidized/hook
Exec hook type runs a user defined command with or without shell. It
populates a bunch of environment variables with metadata. The command
can either be run as synchronous or asynchronous. The default is
synchronous.
Diffstat (limited to 'lib/oxidized/worker.rb')
-rw-r--r-- | lib/oxidized/worker.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 6bb2a22..eea747e 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -34,12 +34,16 @@ module Oxidized @jobs.duration job.time node.running = false if job.status == :success + Oxidized.Hooks.handle :node_success, :node => node, + :job => job msg = "update #{node.name}" msg += " from #{node.from}" if node.from msg += " with message '#{node.msg}'" if node.msg if node.output.new.store node.name, job.config, :msg => msg, :user => node.user, :group => node.group Log.info "Configuration updated for #{node.group}/#{node.name}" + Oxidized.Hooks.handle :post_store, :node => node, + :job => job end node.reset else @@ -51,6 +55,8 @@ module Oxidized else msg += ", retries exhausted, giving up" node.retry = 0 + Oxidized.Hooks.handle :node_fail, :node => node, + :job => job end Log.warn msg end |