From 9db28a09e8f7695f67297fff7f7144bac2061cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 24 Nov 2016 20:19:28 +0100 Subject: Add ranch:info/0 and ranch:procs/2 Provides detailed information about Ranch listeners --- doc/src/guide/listeners.asciidoc | 23 +++++++++++++++++++++++ doc/src/manual/ranch.asciidoc | 28 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) (limited to 'doc') diff --git a/doc/src/guide/listeners.asciidoc b/doc/src/guide/listeners.asciidoc index 7a5bdb2..1055b80 100644 --- a/doc/src/guide/listeners.asciidoc +++ b/doc/src/guide/listeners.asciidoc @@ -277,3 +277,26 @@ calling `ranch:get_protocol_options/1`. [source,erlang] Opts = ranch:get_protocol_options(tcp_echo). + +=== Obtain information about listeners + +Ranch provides two functions for retrieving information about the +listeners, for reporting and diagnostic purposes. + +The `ranch:info/0` function will return detailed information +about all listeners. + +.Retrieving detailed information +[source,erlang] +ranch:info(). + +The `ranch:procs/2` function will return all acceptor or listener +processes for a given listener. + +.Get all acceptor processes +[source,erlang] +ranch:procs(tcp_echo, acceptors). + +.Get all connection processes +[source,erlang] +ranch:procs(tcp_echo, connections). diff --git a/doc/src/manual/ranch.asciidoc b/doc/src/manual/ranch.asciidoc index 2e4f177..13380fd 100644 --- a/doc/src/manual/ranch.asciidoc +++ b/doc/src/manual/ranch.asciidoc @@ -111,6 +111,34 @@ ProtoOpts = any():: Current protocol options. Return the protocol options set for the given listener. +=== info() -> [{Ref, [{Key, Value}]}] + +Ref = ref():: Listener name. +Key = atom():: Information key. +Value = any():: Information value. + +Return detailed information about all Ranch listeners. + +The following keys are defined: + +pid:: Pid of the listener's top-level supervisor. +ip:: Interface Ranch listens on. +port:: Port number Ranch listens on. +num_acceptors:: Number of acceptor processes. +max_connections:: Maximum number of connections. +active_connections:: Number of active connections. +all_connections:: Number of connections, including those removed from the count. +transport:: Transport module. +transport_options:: Transport options. +protocol:: Protocol module. +protocol_options:: Protocol options. + +=== procs(Ref, acceptors | connections) -> [pid()] + +Ref = ref():: Listener name. + +Return all acceptor or connection processes for one listener. + === remove_connection(Ref) -> ok Ref = ref():: Listener name. -- cgit v1.2.3