Sha256: 8ee7ce9de12df5c0f9418f3f8a7130b5b0c131847f69a8839f54d210a0e72753

Contents?: true

Size: 563 Bytes

Versions: 43

Compression:

Stored size: 563 Bytes

Contents

class Netstat
	
	include RunCommand
	
	command :netstat, :naplev => ""
	
	def data
		headers = false
		output = {}
		command_output.split("\n").each do |line|
			if line[/^Active /,0]
				type = line.split(" ")[1]
			end
			if line[/^Proto /,0]
				fmt = line.split(/ \b/).map {|v| [v.strip.downcase.to_sym,v.length]}
				fmt[fmt.size-1][1] = 99
				next
			end
			next unless fmt
			pkt = {}
			fmt.each do |(name,length)|
				val = line.slice!(0..length-1).strip
				pkt[name] = val
			end
			output[type] ||= []
			output[type] << pkt
		end
		output
	end
	
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
city-watch-0.7.9 lib/city_watch/commands/netstat.rb
city-watch-0.7.8 lib/city_watch/commands/netstat.rb
city-watch-0.7.7 lib/city_watch/commands/netstat.rb
city-watch-0.7.6 lib/city_watch/commands/netstat.rb
city-watch-0.7.5 lib/city_watch/commands/netstat.rb
city-watch-0.7.4 lib/city_watch/commands/netstat.rb
city-watch-0.7.3 lib/city_watch/commands/netstat.rb
city-watch-0.7.2 lib/city_watch/commands/netstat.rb
city-watch-0.7.1 lib/city_watch/commands/netstat.rb
city-watch-0.7.0 lib/city_watch/commands/netstat.rb
city-watch-0.6.9 lib/city_watch/commands/netstat.rb
city-watch-0.6.8 lib/city_watch/commands/netstat.rb
city-watch-0.6.7 lib/city_watch/commands/netstat.rb
city-watch-0.6.6 lib/city_watch/commands/netstat.rb
city-watch-0.6.5 lib/city_watch/commands/netstat.rb
city-watch-0.6.4 lib/city_watch/commands/netstat.rb
city-watch-0.6.3 lib/city_watch/commands/netstat.rb
city-watch-0.6.2 lib/city_watch/commands/netstat.rb
city-watch-0.6.1 lib/city_watch/commands/netstat.rb
city-watch-0.6.0 lib/city_watch/commands/netstat.rb