fix: nothing show when run clients list command
This commit is contained in:
parent
574dc2f243
commit
8e7ba16c3a
|
@ -157,7 +157,10 @@ sort_map_list_field(Field, Map) ->
|
||||||
%% @doc Query clients
|
%% @doc Query clients
|
||||||
|
|
||||||
clients(["list"]) ->
|
clients(["list"]) ->
|
||||||
dump(?CHAN_TAB, client);
|
case ets:info(?CHAN_TAB, size) of
|
||||||
|
0 -> emqx_ctl:print("No clients.~n");
|
||||||
|
_ -> dump(?CHAN_TAB, client)
|
||||||
|
end;
|
||||||
clients(["show", ClientId]) ->
|
clients(["show", ClientId]) ->
|
||||||
if_client(ClientId, fun print/1);
|
if_client(ClientId, fun print/1);
|
||||||
clients(["kick", ClientId]) ->
|
clients(["kick", ClientId]) ->
|
||||||
|
@ -180,10 +183,15 @@ if_client(ClientId, Fun) ->
|
||||||
%% @doc Topics Command
|
%% @doc Topics Command
|
||||||
|
|
||||||
topics(["list"]) ->
|
topics(["list"]) ->
|
||||||
emqx_router:foldr_routes(
|
Res =
|
||||||
fun(Route, Acc) -> [print({emqx_topic, Route}) | Acc] end,
|
emqx_router:foldr_routes(
|
||||||
[]
|
fun(Route, Acc) -> [print({emqx_topic, Route}) | Acc] end,
|
||||||
);
|
[]
|
||||||
|
),
|
||||||
|
case Res of
|
||||||
|
[] -> emqx_ctl:print("No topics.~n");
|
||||||
|
_ -> ok
|
||||||
|
end;
|
||||||
topics(["show", Topic]) ->
|
topics(["show", Topic]) ->
|
||||||
Routes = emqx_router:lookup_routes(Topic),
|
Routes = emqx_router:lookup_routes(Topic),
|
||||||
[print({emqx_topic, Route}) || Route <- Routes];
|
[print({emqx_topic, Route}) || Route <- Routes];
|
||||||
|
@ -194,12 +202,17 @@ topics(_) ->
|
||||||
]).
|
]).
|
||||||
|
|
||||||
subscriptions(["list"]) ->
|
subscriptions(["list"]) ->
|
||||||
lists:foreach(
|
case ets:info(?SUBOPTION, size) of
|
||||||
fun(Suboption) ->
|
0 ->
|
||||||
print({?SUBOPTION, Suboption})
|
emqx_ctl:print("No subscriptions.~n");
|
||||||
end,
|
_ ->
|
||||||
ets:tab2list(?SUBOPTION)
|
lists:foreach(
|
||||||
);
|
fun(SubOption) ->
|
||||||
|
print({?SUBOPTION, SubOption})
|
||||||
|
end,
|
||||||
|
ets:tab2list(?SUBOPTION)
|
||||||
|
)
|
||||||
|
end;
|
||||||
subscriptions(["show", ClientId]) ->
|
subscriptions(["show", ClientId]) ->
|
||||||
case ets:lookup(emqx_subid, bin(ClientId)) of
|
case ets:lookup(emqx_subid, bin(ClientId)) of
|
||||||
[] ->
|
[] ->
|
||||||
|
@ -207,7 +220,7 @@ subscriptions(["show", ClientId]) ->
|
||||||
[{_, Pid}] ->
|
[{_, Pid}] ->
|
||||||
case ets:match_object(?SUBOPTION, {{'_', Pid}, '_'}) of
|
case ets:match_object(?SUBOPTION, {{'_', Pid}, '_'}) of
|
||||||
[] -> emqx_ctl:print("Not Found.~n");
|
[] -> emqx_ctl:print("Not Found.~n");
|
||||||
Suboption -> [print({?SUBOPTION, Sub}) || Sub <- Suboption]
|
SubOption -> [print({?SUBOPTION, Sub}) || Sub <- SubOption]
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
subscriptions(["add", ClientId, Topic, QoS]) ->
|
subscriptions(["add", ClientId, Topic, QoS]) ->
|
||||||
|
@ -446,13 +459,20 @@ log(_) ->
|
||||||
%% @doc Trace Command
|
%% @doc Trace Command
|
||||||
|
|
||||||
trace(["list"]) ->
|
trace(["list"]) ->
|
||||||
lists:foreach(
|
case emqx_trace_handler:running() of
|
||||||
fun(Trace) ->
|
[] ->
|
||||||
#{type := Type, filter := Filter, level := Level, dst := Dst} = Trace,
|
emqx_ctl:print("Trace is empty~n", []);
|
||||||
emqx_ctl:print("Trace(~s=~s, level=~s, destination=~0p)~n", [Type, Filter, Level, Dst])
|
Traces ->
|
||||||
end,
|
lists:foreach(
|
||||||
emqx_trace_handler:running()
|
fun(Trace) ->
|
||||||
);
|
#{type := Type, filter := Filter, level := Level, dst := Dst} = Trace,
|
||||||
|
emqx_ctl:print("Trace(~s=~s, level=~s, destination=~0p)~n", [
|
||||||
|
Type, Filter, Level, Dst
|
||||||
|
])
|
||||||
|
end,
|
||||||
|
Traces
|
||||||
|
)
|
||||||
|
end;
|
||||||
trace(["stop", Operation, Filter0]) ->
|
trace(["stop", Operation, Filter0]) ->
|
||||||
case trace_type(Operation, Filter0) of
|
case trace_type(Operation, Filter0) of
|
||||||
{ok, Type, Filter} -> trace_off(Type, Filter);
|
{ok, Type, Filter} -> trace_off(Type, Filter);
|
||||||
|
|
Loading…
Reference in New Issue