From 1c3e0a2575c0644a7fca02bbe865e2ce421f5adb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 1 Mar 2011 00:57:35 +0000 Subject: [PATCH] linux-listener-stats: not just for TCP... This can now be used to monitor UNIX domain socket queues, too. --- .../{linux-tcp-listener-stats.rb => linux-listener-stats.rb} | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) rename examples/{linux-tcp-listener-stats.rb => linux-listener-stats.rb} (81%) diff --git a/examples/linux-tcp-listener-stats.rb b/examples/linux-listener-stats.rb similarity index 81% rename from examples/linux-tcp-listener-stats.rb rename to examples/linux-listener-stats.rb index 522882a..73b100f 100755 --- a/examples/linux-tcp-listener-stats.rb +++ b/examples/linux-listener-stats.rb @@ -37,8 +37,15 @@ end fmt = "% 19s % 10u % 10u\n" printf fmt.tr('u','s'), *%w(address active queued) +tcp, unix = [], [] +ARGV.each { |addr| (addr =~ %r{\A/} ? unix : tcp) << addr } +stats = {} +tcp = nil if tcp.empty? +unix = nil if unix.empty? begin - stats = Raindrops::Linux.tcp_listener_stats(ARGV) + stats.clear + tcp and stats.merge! Raindrops::Linux.tcp_listener_stats(tcp) + unix and stats.merge! Raindrops::Linux.unix_listener_stats(unix) stats.each { |addr,stats| printf fmt, addr, stats.active, stats.queued } end while delay && sleep(delay) -- 2.11.4.GIT