Created
April 8, 2016 21:19
-
-
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"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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