about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-03-14 14:50:43 -0700
committerEric Wong <normalperson@yhbt.net>2011-03-14 14:50:43 -0700
commit724f82bb5feaf1df40b02b8f353e94496f060647 (patch)
tree1fc23a1bc64c690581cbf05edb1f00429e97fef2
parent65f46737ad5641841a5e5a89f4651d160dacffc0 (diff)
downloadraindrops-724f82bb5feaf1df40b02b8f353e94496f060647.tar.gz
Sometimes we want more of them
-rwxr-xr-xexamples/linux-listener-stats.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/examples/linux-listener-stats.rb b/examples/linux-listener-stats.rb
index 70d60c6..3494dff 100755
--- a/examples/linux-listener-stats.rb
+++ b/examples/linux-listener-stats.rb
@@ -11,6 +11,7 @@ require 'time'
 usage = "Usage: #$0 [-d DELAY] [-t QUEUED_THRESHOLD] ADDR..."
 ARGV.size > 0 or abort usage
 delay = false
+all_tcp = true
 queued_thresh = -1
 # "normal" exits when driven on the command-line
 trap(:INT) { exit 130 }
@@ -20,6 +21,7 @@ opts = OptionParser.new('', 24, '  ') do |opts|
   opts.banner = usage
   opts.on('-d', '--delay=DELAY', Float) { |n| delay = n }
   opts.on('-t', '--queued-threshold=INT', Integer) { |n| queued_thresh = n }
+  opts.on('-a', '--all-tcp') { all_tcp = true }
   opts.parse! ARGV
 end
 
@@ -77,7 +79,13 @@ ARGV.each do |addr|
   (addr =~ %r{\A/} ? unix : tcp) << addr
 end
 combined = {}
-tcp = nil if tcp.empty?
+if all_tcp
+  tcp = true
+  tcp_arg = nil
+else
+  tcp_arg = tcp
+end
+
 unix = nil if unix.empty?
 sock = Raindrops::InetDiagSocket.new if tcp
 
@@ -90,7 +98,7 @@ begin
     combined.clear
     now = nil
   end
-  tcp and combined.merge! Raindrops::Linux.tcp_listener_stats(tcp, sock)
+  tcp and combined.merge! Raindrops::Linux.tcp_listener_stats(tcp_arg, sock)
   unix and combined.merge! Raindrops::Linux.unix_listener_stats(unix)
   combined.each do |addr,stats|
     active, queued = stats.active, stats.queued