Module: IPScanner

Defined in:
lib/networkwatcherd/ipscanner.rb

Class Method Summary collapse

Class Method Details

.network_devices(nd, ip_pattern) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/networkwatcherd/ipscanner.rb', line 4

def self.network_devices(nd,ip_pattern)
  (1..nd).each do |n|
    ip = "#{ip_pattern}.#{n}"
    output = `ping -c1 #{ip}`
    data = output.split
    #p data[12]
    if data[12] != "Unreachable"
      device_raw_ip = data[1]
      if device_raw_ip != nil
        device = NetworkDevices.new(device_raw_ip)
        yield device
      end
    end
      #p n
    end

end