Class: MMTop::ReverseLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/mmtop/filters/reverse_lookup.rb

Class Method Summary collapse

Class Method Details

.lookup(client) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/mmtop/filters/reverse_lookup.rb', line 3

def self.lookup(client)
  return client if client.nil? or client.empty?
  return client unless client =~ /\d+\.\d+\.\d+\.\d+/

  @@lookups ||= {}

  return @@lookups[client] if @@lookups[client]

  hostline = %x{dig -x #{client} +short}.split("\n").first.to_s
  hostline.gsub!(/([^\.]+)\..*/, '\1')
  @@lookups[client] = hostline
  @@lookups[client] 
end