From 724f82bb5feaf1df40b02b8f353e94496f060647 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Mar 2011 14:50:43 -0700 Subject: linux-listener-stats: allow -a for all TCP sockets Sometimes we want more of them --- examples/linux-listener-stats.rb | 12 ++++++++++-- 1 file 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 -- cgit v1.2.3-24-ge0c7