* [ANN] raindrops 0.18.0 - real-time stats for preforking Rack servers
@ 2017-03-23 2:48 6% Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2017-03-23 2:48 UTC (permalink / raw)
To: ruby-talk, raindrops-public; +Cc: unicorn-public, Simon Eskildsen, Jeremy Evans
raindrops is a real-time stats toolkit to show statistics for Rack HTTP
servers. It is designed for preforking servers such as unicorn, but
should support any Rack HTTP server on platforms supporting POSIX shared
memory. It may also be used as a generic scoreboard for sharing atomic
counters across multiple processes.
* https://bogomips.org/raindrops/
* No subscription necessary, no HTML mail:
raindrops-public@bogomips.org
* mail archives: https://bogomips.org/raindrops-public/
http://ou63pmih66umazou.onion/raindrops-public/
nntp://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.raindrops
* git clone git://bogomips.org/raindrops.git
* https://bogomips.org/raindrops/NEWS.atom.xml
* Demo site: https://raindrops-demo.bogomips.org:8443/
Changes:
raindrops 0.18.0
The most notable feature of this release is the addition of
FreeBSD and OpenBSD TCP_INFO support. This includes the
Raindrops::TCP for portably mapping TCP state names to
platform-dependent numeric values:
https://bogomips.org/raindrops/Raindrops.html#TCP
Thanks to Jeremy Evans and Simon Eskildsen on the
unicorn-public@bogomips.org mailing list for inspiring
these changes to raindrops.
There's also a few internal cleanups, and documentation
improvements, including some fixes to the largely-forgotten
Raindrops::Aggreage::PMQ class:
https://bogomips.org/raindrops/Raindrops/Aggregate/PMQ.html
20 changes since 0.17.0:
test_inet_diag_socket: fix Fixnum deprecation warning
TODO: add item for IPv6 breakage
ext: fix documentation for C ext-defined classes
TCP_Info: custom documentation for #get!
TypedData C-API conversion
test_watcher: disable test correctly when aggregate is missing
tcp_info: support this struct under FreeBSD
define Raindrops::TCP hash for TCP states
linux_inet_diag: reduce stack usage and simplify
avoid reading errno repeatedly
aggregate/pmq: avoid false sharing of lock buffers
aggregate/pmq: remove io-extra requirement
aggregate/pmq: avoid File#stat allocation
Merge remote-tracking branch 'origin/freebsd'
Merge remote-tracking branch 'origin/aggregate-pmq'
doc: remove private email support address
doc: update location of TCP_INFO-related stuff
build: avoid olddoc for building the RubyGem
doc: document Raindrops::TCP hash
aggregate/pmq: update version numbers for Ruby and Linux
^ permalink raw reply [relevance 6%]
* [PATCH 0/2] support TCP_INFO under FreeBSD
@ 2017-03-16 3:16 7% Eric Wong
2017-03-16 3:16 6% ` [PATCH 2/2] define Raindrops::TCP hash for TCP states Eric Wong
0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2017-03-16 3:16 UTC (permalink / raw)
To: raindrops-public
FreeBSD seems to have useful enough TCP_INFO support for
checking TCP states and such.
Eric Wong (2):
tcp_info: support this struct under FreeBSD
define Raindrops::TCP hash for TCP states
ext/raindrops/extconf.rb | 105 ++++++++++-
ext/raindrops/linux_tcp_info.c | 196 --------------------
ext/raindrops/raindrops.c | 8 +-
ext/raindrops/tcp_info.c | 216 ++++++++++++++++++++++
test/{test_linux_tcp_info.rb => test_tcp_info.rb} | 40 +++-
5 files changed, 356 insertions(+), 209 deletions(-)
^ permalink raw reply [relevance 7%]
* [PATCH 2/2] define Raindrops::TCP hash for TCP states
2017-03-16 3:16 7% [PATCH 0/2] support TCP_INFO under FreeBSD Eric Wong
@ 2017-03-16 3:16 6% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2017-03-16 3:16 UTC (permalink / raw)
To: raindrops-public
FreeBSD not only uses different values than Linux for TCP
states, but different names, too. To ease writing portable code
between the OSes, do more CPP metaprogramming via extconf.rb
and define a common hash supported on both OSes.
Putting all this in a hash allows for easy dumping and mapping
in an OS-neutral way, since the actual TCP states are
OS-independent.
---
ext/raindrops/extconf.rb | 27 +++++++++++++++++++++++++++
ext/raindrops/tcp_info.c | 21 +++++++++++++++++++++
test/test_tcp_info.rb | 3 +++
3 files changed, 51 insertions(+)
diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index 5273b74..86c7d78 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -82,6 +82,33 @@
"#{Shellwords.shellescape(
%Q[rb_define_method(cTCP_Info,#{rbmethod},#{cfunc},0)])}"
end
+ tcp_state_map = {
+ ESTABLISHED: %w(TCP_ESTABLISHED TCPS_ESTABLISHED),
+ SYN_SENT: %w(TCP_SYN_SENT TCPS_SYN_SENT),
+ SYN_RECV: %w(TCP_SYN_RECV TCPS_SYN_RECEIVED),
+ FIN_WAIT1: %w(TCP_FIN_WAIT1 TCPS_FIN_WAIT_1),
+ FIN_WAIT2: %w(TCP_FIN_WAIT2 TCPS_FIN_WAIT_2),
+ TIME_WAIT: %w(TCP_TIME_WAIT TCPS_TIME_WAIT),
+ CLOSE: %w(TCP_CLOSE TCPS_CLOSED),
+ CLOSE_WAIT: %w(TCP_CLOSE_WAIT TCPS_CLOSE_WAIT),
+ LAST_ACK: %w(TCP_LAST_ACK TCPS_LAST_ACK),
+ LISTEN: %w(TCP_LISTEN TCPS_LISTEN),
+ CLOSING: %w(TCP_CLOSING TCPS_CLOSING),
+ }
+ nstate = 0
+ tcp_state_map.each do |state, try|
+ try.each do |os_name|
+ have_const(os_name, headers) or next
+ tcp_state_map[state] = os_name
+ nstate += 1
+ end
+ end
+ if nstate == tcp_state_map.size
+ $defs << '-DRAINDROPS_TCP_STATES_ALL_KNOWN=1'
+ tcp_state_map.each do |state, name|
+ $defs << "-DRAINDROPS_TCP_#{state}=#{name}"
+ end
+ end
end
have_func("getpagesize", "unistd.h")
diff --git a/ext/raindrops/tcp_info.c b/ext/raindrops/tcp_info.c
index dc615f7..3e241a1 100644
--- a/ext/raindrops/tcp_info.c
+++ b/ext/raindrops/tcp_info.c
@@ -191,5 +191,26 @@ void Init_raindrops_tcp_info(void)
DEFINE_METHOD_tcp_info_tcpi_rcv_rtt;
DEFINE_METHOD_tcp_info_tcpi_rcv_space;
DEFINE_METHOD_tcp_info_tcpi_total_retrans;
+
+#ifdef RAINDROPS_TCP_STATES_ALL_KNOWN
+ {
+#define TCPSET(n,v) rb_hash_aset(tcp, ID2SYM(rb_intern(#n)), INT2NUM(v))
+ VALUE tcp = rb_hash_new();
+ TCPSET(ESTABLISHED, RAINDROPS_TCP_ESTABLISHED);
+ TCPSET(SYN_SENT, RAINDROPS_TCP_SYN_SENT);
+ TCPSET(SYN_RECV, RAINDROPS_TCP_SYN_RECV);
+ TCPSET(FIN_WAIT1, RAINDROPS_TCP_FIN_WAIT1);
+ TCPSET(FIN_WAIT2, RAINDROPS_TCP_FIN_WAIT2);
+ TCPSET(TIME_WAIT, RAINDROPS_TCP_TIME_WAIT);
+ TCPSET(CLOSE, RAINDROPS_TCP_CLOSE);
+ TCPSET(CLOSE_WAIT, RAINDROPS_TCP_CLOSE_WAIT);
+ TCPSET(LAST_ACK, RAINDROPS_TCP_LAST_ACK);
+ TCPSET(LISTEN, RAINDROPS_TCP_LISTEN);
+ TCPSET(CLOSING, RAINDROPS_TCP_CLOSING);
+#undef TCPSET
+ OBJ_FREEZE(tcp);
+ rb_define_const(cRaindrops, "TCP", tcp);
+ }
+#endif
}
#endif /* HAVE_STRUCT_TCP_INFO */
diff --git a/test/test_tcp_info.rb b/test/test_tcp_info.rb
index 15df087..b107565 100644
--- a/test/test_tcp_info.rb
+++ b/test/test_tcp_info.rb
@@ -73,6 +73,9 @@ def test_tcp_server_state_closed
a = s.accept
i.get!(a)
state = i.state
+ if Raindrops.const_defined?(:TCP)
+ assert_equal state, Raindrops::TCP[:ESTABLISHED]
+ end
c = c.close
sleep(0.01) # wait for kernel to update state
i.get!(a)
--
EW
^ permalink raw reply related [relevance 6%]
Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-03-16 3:16 7% [PATCH 0/2] support TCP_INFO under FreeBSD Eric Wong
2017-03-16 3:16 6% ` [PATCH 2/2] define Raindrops::TCP hash for TCP states Eric Wong
2017-03-23 2:48 6% [ANN] raindrops 0.18.0 - real-time stats for preforking Rack servers Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/raindrops.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).