Class: NSCA::Client::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/nsca/client/message.rb

Constant Summary collapse

CODE =
{ :ok => 0, :warn => 1, :critical => 2 }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alert, status, service, remote_server) ⇒ Message

Returns a new instance of Message.



8
9
10
11
12
13
# File 'lib/nsca/client/message.rb', line 8

def initialize(alert, status, service, remote_server)
  @return_code = CODE[alert]
  @status = status
  @service = service
  @remote_server = remote_server
end

Instance Attribute Details

#return_codeObject (readonly)

Returns the value of attribute return_code.



6
7
8
# File 'lib/nsca/client/message.rb', line 6

def return_code
  @return_code
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/nsca/client/message.rb', line 15

def to_h
  {
    :nscahost    => @remote_server.host,
    :port        => @remote_server.port,
    :hostname    => @service.host.hostname,
    :service     => @service.name,
    :return_code => @return_code,
    :status      => @status
  }
end