class ElasticNotifier::Signal

Attributes

attributes[R]

Public Class Methods

new(overrides = {}) click to toggle source
# File lib/elastic_notifier/signal.rb, line 5
def initialize(overrides = {})
  @pid = Process.pid
  @hostname = Socket.gethostname
  @ip = find_ip_address
  @timestamp = Time.now.strftime('%Y-%m-%dT%H:%M:%S')
  @program_name = $PROGRAM_NAME
  @overrides = overrides
end

Public Instance Methods

data() click to toggle source
# File lib/elastic_notifier/signal.rb, line 30
def data
  raise NotImplementedError
end
severity() click to toggle source
# File lib/elastic_notifier/signal.rb, line 26
def severity
  raise NotImplementedError
end
to_hash() click to toggle source
# File lib/elastic_notifier/signal.rb, line 14
def to_hash
  {
    severity: severity,
    timestamp: @timestamp,
    program_name: @program_name,
    pid: @pid,
    hostname: @hostname,
    ip: @ip,
    data: data
  }.merge(@overrides)
end

Private Instance Methods

find_ip_address() click to toggle source
# File lib/elastic_notifier/signal.rb, line 36
def find_ip_address
  Socket.ip_address_list.find { |ip| ip.ipv4? && !ip.ipv4_loopback? }.ip_address
end