Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

get the number of running connections

GET /_stats/httpd/connections
  • Loading branch information...
commit e394ea364f46ad6ff47add540dbcf2e88463eb0f 1 parent 1c1df4d
@benoitc benoitc authored
View
4 apps/couch_httpd/src/couch_httpd_protocol.erl
@@ -148,7 +148,7 @@ after_response(Body, Req) ->
case Req:should_close() of
true ->
mochiweb_socket:close(Socket),
- ok;
+ exit(normal);
false ->
Req:cleanup(),
erlang:garbage_collect(),
@@ -169,4 +169,4 @@ mochiweb_socket(#hstate{transport=Transport, socket=Socket}) ->
terminate(#hstate{transport=Transport, socket=Socket}) ->
Transport:close(Socket),
- ok.
+ exit(normal).
View
13 apps/couch_httpd/src/couch_httpd_stats_handlers.erl
@@ -56,6 +56,18 @@ handle_stats_req(#httpd{method='GET',
path_parts=[_, <<"vm">>, <<"dets">>]}=Req) ->
flush(Req),
send_vm_json(Req, couch_stats_vm:get_dets_info());
+handle_stats_req(#httpd{method='GET',
+ path_parts=[_, <<"httpd">>, <<"connections">>]}=Req) ->
+ flush(Req),
+
+ NbConns = lists:foldl(fun(Ref, Sum) ->
+ N = ranch_server:count_connections(Ref),
+ Sum + N
+ end, 0, couch_httpd:get_bindings()),
+
+ send_json(Req, {[{<<"httpd">>, {[{<<"connections">>, NbConns}]}}]});
+
+
handle_stats_req(#httpd{method='GET', path_parts=[_, Mod, Key]}=Req) ->
flush(Req),
Stats = couch_stats_aggregator:get_json({list_to_atom(binary_to_list(Mod)),
@@ -70,6 +82,7 @@ handle_stats_req(Req) ->
+
send_vm_json(Req, Value) ->
couch_httpd:initialize_jsonp(Req),
Headers = [
Please sign in to comment.
Something went wrong with that request. Please try again.