about summary refs log tree commit homepage
path: root/examples
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-03-01 00:57:35 +0000
committerEric Wong <normalperson@yhbt.net>2011-03-01 00:57:35 +0000
commit1c3e0a2575c0644a7fca02bbe865e2ce421f5adb (patch)
treee66e2b310f0c697155bc30f9e35418e5402ca396 /examples
parent6d12a518f69f950d814eb223fe5bf1ad448dcc34 (diff)
downloadraindrops-1c3e0a2575c0644a7fca02bbe865e2ce421f5adb.tar.gz
This can now be used to monitor UNIX domain socket queues, too.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/linux-listener-stats.rb (renamed from examples/linux-tcp-listener-stats.rb)9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/linux-tcp-listener-stats.rb b/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)