@@ -59,10 +59,10 @@ start_link() ->
5959stop_all_mqtt_listeners (KillSessions ) ->
6060 lists :foreach (
6161 fun
62- ({mqtt , Addr , Port , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
63- ({mqtts , Addr , Port , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
64- ({mqttws , Addr , Port , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
65- ({mqttwss , Addr , Port , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
62+ ({mqtt , Addr , Port , _ , _ , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
63+ ({mqtts , Addr , Port , _ , _ , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
64+ ({mqttws , Addr , Port , _ , _ , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
65+ ({mqttwss , Addr , Port , _ , _ , _ , _ , _ , _ }) -> stop_listener (Addr , Port , KillSessions );
6666 (_ ) -> ignore
6767 end ,
6868 listeners ()
@@ -135,51 +135,38 @@ start_listener(Type, Addr, Port, {TransportOpts, Opts}) ->
135135 end .
136136
137137listeners () ->
138- lists :foldl (
139- fun
140- ({ranch_server , _ , _ , _ }, Acc ) ->
141- Acc ;
142- ({{ranch_listener_sup , {Ip , Port }}, Status , supervisor , _ }, Acc ) ->
143- {ok , {Type , Opts }} = get_listener_config (Ip , Port ),
144- MountPoint = proplists :get_value (mountpoint , Opts , " " ),
145- MaxConnections = proplists :get_value (
146- max_connections ,
147- Opts ,
148- vmq_config :get_env (max_connections )
149- ),
150- Status1 =
151- case Status of
152- restarting ->
153- restarting ;
154- undefined ->
155- stopped ;
156- Pid when is_pid (Pid ) ->
157- case
158- lists :keyfind (
159- ranch_acceptors_sup , 1 , supervisor :which_children (Pid )
160- )
161- of
162- false ->
163- not_found ;
164- {_ , restarting , supervisor , _ } ->
165- restarting ;
166- {_ , undefined , supervisor , _ } ->
167- stopped ;
168- {_ , AcceptorPid , supervisor , _ } when is_pid (AcceptorPid ) ->
169- running
170- end
171- end ,
172- StrIp = inet :ntoa (Ip ),
173- StrPort = integer_to_list (Port ),
174- ProxyProtocol = proplists :get_value (
175- proxy_protocol ,
176- Opts ,
177- false
178- ),
179- [{Type , StrIp , StrPort , Status1 , MountPoint , MaxConnections , ProxyProtocol } | Acc ]
138+ maps :fold (
139+ fun ({Ip , Port }, ConfigMap , Acc ) ->
140+ {ok , {Type , Opts }} = get_listener_config (Ip , Port ),
141+ MountPoint = proplists :get_value (mountpoint , Opts , " " ),
142+ MaxConnections = proplists :get_value (
143+ max_connections ,
144+ Opts ,
145+ vmq_config :get_env (max_connections )
146+ ),
147+ ActiveConnections = maps :get (active_connections , ConfigMap ),
148+ % the highest number of connections seen
149+ AllConnections = maps :get (all_connections , ConfigMap ),
150+ Status = maps :get (status , ConfigMap ),
151+ StrIp =
152+ case Ip of
153+ {local , FS } -> {local , FS };
154+ _ -> inet :ntoa (Ip )
155+ end ,
156+ StrPort = integer_to_list (Port ),
157+ ProxyProtocol = proplists :get_value (
158+ proxy_protocol ,
159+ Opts ,
160+ false
161+ ),
162+ [
163+ {Type , StrIp , StrPort , Status , MountPoint , MaxConnections , ProxyProtocol ,
164+ ActiveConnections , AllConnections }
165+ | Acc
166+ ]
180167 end ,
181168 [],
182- supervisor : which_children ( ranch_sup )
169+ ranch : info ( )
183170 ).
184171
185172get_listener_config (Addr , Port ) ->
0 commit comments