Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save drewdeponte/b404861a25a2bd9b7e082b90329daf80 to your computer and use it in GitHub Desktop.
Save drewdeponte/b404861a25a2bd9b7e082b90329daf80 to your computer and use it in GitHub Desktop.
print netstat from proc watch -n 1 "cat /proc/net/netstat | ./drew_netstat.rb"
#!/usr/bin/env ruby
stats_hash = {}
stats_lines = $stdin.readlines
headers = stats_lines[0].gsub(/TcpExt: /, '').split(' ')
stats = stats_lines[1].gsub(/TcpExt: /, '').split(' ')
headers.each_index do |i|
stats_hash[headers[i]] = stats[i]
end
stats_hash.each_pair do |k, v|
$stdout.puts "#{k}: #{v}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment