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
|
||||
|
||||
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]) ->
|
||||
if_client(ClientId, fun print/1);
|
||||
clients(["kick", ClientId]) ->
|
||||
|
@ -180,10 +183,15 @@ if_client(ClientId, Fun) ->
|
|||
%% @doc Topics Command
|
||||
|
||||
topics(["list"]) ->
|
||||
Res =
|
||||
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]) ->
|
||||
Routes = emqx_router:lookup_routes(Topic),
|
||||
[print({emqx_topic, Route}) || Route <- Routes];
|
||||
|
@ -194,12 +202,17 @@ topics(_) ->
|
|||
]).
|
||||
|
||||
subscriptions(["list"]) ->
|
||||
case ets:info(?SUBOPTION, size) of
|
||||
0 ->
|
||||
emqx_ctl:print("No subscriptions.~n");
|
||||
_ ->
|
||||
lists:foreach(
|
||||
fun(Suboption) ->
|
||||
print({?SUBOPTION, Suboption})
|
||||
fun(SubOption) ->
|
||||
print({?SUBOPTION, SubOption})
|
||||
end,
|
||||
ets:tab2list(?SUBOPTION)
|
||||
);
|
||||
)
|
||||
end;
|
||||
subscriptions(["show", ClientId]) ->
|
||||
case ets:lookup(emqx_subid, bin(ClientId)) of
|
||||
[] ->
|
||||
|
@ -207,7 +220,7 @@ subscriptions(["show", ClientId]) ->
|
|||
[{_, Pid}] ->
|
||||
case ets:match_object(?SUBOPTION, {{'_', Pid}, '_'}) of
|
||||
[] -> emqx_ctl:print("Not Found.~n");
|
||||
Suboption -> [print({?SUBOPTION, Sub}) || Sub <- Suboption]
|
||||
SubOption -> [print({?SUBOPTION, Sub}) || Sub <- SubOption]
|
||||
end
|
||||
end;
|
||||
subscriptions(["add", ClientId, Topic, QoS]) ->
|
||||
|
@ -446,13 +459,20 @@ log(_) ->
|
|||
%% @doc Trace Command
|
||||
|
||||
trace(["list"]) ->
|
||||
case emqx_trace_handler:running() of
|
||||
[] ->
|
||||
emqx_ctl:print("Trace is empty~n", []);
|
||||
Traces ->
|
||||
lists:foreach(
|
||||
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])
|
||||
emqx_ctl:print("Trace(~s=~s, level=~s, destination=~0p)~n", [
|
||||
Type, Filter, Level, Dst
|
||||
])
|
||||
end,
|
||||
emqx_trace_handler:running()
|
||||
);
|
||||
Traces
|
||||
)
|
||||
end;
|
||||
trace(["stop", Operation, Filter0]) ->
|
||||
case trace_type(Operation, Filter0) of
|
||||
{ok, Type, Filter} -> trace_off(Type, Filter);
|
||||
|
|
Loading…
Reference in New Issue