Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Track connection node and username
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Feb 3, 2016
1 parent 7375646 commit 9720d12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/rabbit.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@
%% used to track connections across virtual hosts
%% e.g. so that limits can be enforced
-record(tracked_connection, {
%% {Node, Name}
id,
node,
vhost,
name,
pid,
Expand All @@ -151,6 +154,7 @@
peer_host,
%% client port
peer_port,
username,
%% time of connection
connected_at
}).
Expand Down
7 changes: 5 additions & 2 deletions src/rabbit_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@
peer_host, ssl, peer_cert_subject, peer_cert_issuer,
peer_cert_validity, auth_mechanism, ssl_protocol,
ssl_key_exchange, ssl_cipher, ssl_hash, protocol, user, vhost,
timeout, frame_max, channel_max, client_properties, connected_at]).
timeout, frame_max, channel_max, client_properties, connected_at,
node]).

-define(INFO_KEYS, ?CREATION_EVENT_KEYS ++ ?STATISTICS_KEYS -- [pid]).

Expand Down Expand Up @@ -400,7 +401,8 @@ start_connection(Parent, HelperSup, Deb, Sock) ->
rabbit_net:fast_close(Sock),
rabbit_networking:unregister_connection(self()),
rabbit_event:notify(connection_closed, [{name, list_to_binary(Name)},
{pid, self()}])
{pid, self()},
{node, node()}])
end,
done.

Expand Down Expand Up @@ -1375,6 +1377,7 @@ notify_auth_result(Username, AuthResult, ExtraProps, State) ->
infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items].

i(pid, #v1{}) -> self();
i(node, #v1{}) -> node();
i(SockStat, S) when SockStat =:= recv_oct;
SockStat =:= recv_cnt;
SockStat =:= send_oct;
Expand Down

0 comments on commit 9720d12

Please sign in to comment.