Class: Nagira::Writer
- Inherits:
-
Object
- Object
- Nagira::Writer
- Defined in:
- app/writers/external_command_writer.rb
Overview
Singleton class. Handles updates to the of the Nagios external commands file.
Example usage:
Writer.commands = <path to the external command execution file>
Constant Summary collapse
- @@commands =
nil
Instance Attribute Summary collapse
-
#state ⇒ Object
State structure keep all the Nagios parsed state information for :objects, :status, :config, etc.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(action) ⇒ Writer
constructor
A new instance of Writer.
-
#put(params) ⇒ Object
Send PUT update to Nagios::ExternalCommands.
- #write ⇒ Object
Constructor Details
#initialize(action) ⇒ Writer
Returns a new instance of Writer.
12 13 14 |
# File 'app/writers/external_command_writer.rb', line 12 def initialize(action) @action = action end |
Instance Attribute Details
#state ⇒ Object
State structure keep all the Nagios parsed state information for :objects, :status, :config, etc. as well as “inflight” data.
35 36 37 |
# File 'app/writers/external_command_writer.rb', line 35 def state @state end |
Class Method Details
.commands ⇒ Object
43 44 45 |
# File 'app/writers/external_command_writer.rb', line 43 def commands @@commands end |
.commands=(commands_file) ⇒ Object
39 40 41 |
# File 'app/writers/external_command_writer.rb', line 39 def commands=(commands_file) @@commands = Nagios::ExternalCommands.new(commands_file) end |
Instance Method Details
#put(params) ⇒ Object
Send PUT update to Nagios::ExternalCommands
FIXME: This only accepts single service. Modify to use Arrays too
22 23 24 25 26 27 28 |
# File 'app/writers/external_command_writer.rb', line 22 def put(params) res = @@commands.write( params.merge({ :action => @action }) ) { :result => res[:result], :object => res[:data]} end |
#write ⇒ Object
30 31 |
# File 'app/writers/external_command_writer.rb', line 30 def write end |