Class: Nagira::Writer

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#stateObject

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

.commandsObject



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

Parameters:

  • action (Symbol)

    Nagios external command name

  • params (Hash)

    Parsed Hash from PUT request input.



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

#writeObject



30
31
# File 'app/writers/external_command_writer.rb', line 30

def write
end