fix(API): Ensure that the node name is known
This commit is contained in:
parent
d0687c7aaa
commit
60492615ba
|
@ -131,12 +131,20 @@ monitor(get, #{query_string := QS, bindings := Bindings}) ->
|
|||
end.
|
||||
|
||||
monitor_current(get, #{bindings := Bindings}) ->
|
||||
NodeOrCluster = binary_to_atom(maps:get(node, Bindings, <<"all">>), utf8),
|
||||
RawNode = maps:get(node, Bindings, all),
|
||||
case emqx_misc:safe_to_existing_atom(RawNode, utf8) of
|
||||
{ok, NodeOrCluster} ->
|
||||
case emqx_dashboard_monitor:current_rate(NodeOrCluster) of
|
||||
{ok, CurrentRate} ->
|
||||
{200, CurrentRate};
|
||||
{badrpc, {Node, Reason}} ->
|
||||
Message = list_to_binary(io_lib:format("Bad node ~p, rpc failed ~p", [Node, Reason])),
|
||||
Message = list_to_binary(
|
||||
io_lib:format("Bad node ~p, rpc failed ~p", [Node, Reason])
|
||||
),
|
||||
{400, 'BAD_RPC', Message}
|
||||
end;
|
||||
{error, _} ->
|
||||
Message = list_to_binary(io_lib:format("Bad node ~p", [RawNode])),
|
||||
{400, 'BAD_RPC', Message}
|
||||
end.
|
||||
|
||||
|
|
|
@ -113,7 +113,8 @@ clients(get, #{
|
|||
?QUERY_FUN
|
||||
);
|
||||
Node0 ->
|
||||
Node1 = binary_to_atom(Node0, utf8),
|
||||
case emqx_misc:safe_to_existing_atom(Node0) of
|
||||
{ok, Node1} ->
|
||||
QStringWithoutNode = maps:without([<<"node">>], QString),
|
||||
emqx_mgmt_api:node_query(
|
||||
Node1,
|
||||
|
@ -121,7 +122,10 @@ clients(get, #{
|
|||
TabName,
|
||||
?CLIENT_QSCHEMA,
|
||||
?QUERY_FUN
|
||||
)
|
||||
);
|
||||
{error, _} ->
|
||||
{error, Node0, {badrpc, <<"invalid node">>}}
|
||||
end
|
||||
end,
|
||||
case Result of
|
||||
{error, page_limit_invalid} ->
|
||||
|
|
|
@ -648,7 +648,8 @@ list_clients(QString) ->
|
|||
?QUERY_FUN
|
||||
);
|
||||
Node0 ->
|
||||
Node1 = binary_to_atom(Node0, utf8),
|
||||
case emqx_misc:safe_to_existing_atom(Node0) of
|
||||
{ok, Node1} ->
|
||||
QStringWithoutNode = maps:without([<<"node">>], QString),
|
||||
emqx_mgmt_api:node_query(
|
||||
Node1,
|
||||
|
@ -656,7 +657,10 @@ list_clients(QString) ->
|
|||
?CLIENT_QTAB,
|
||||
?CLIENT_QSCHEMA,
|
||||
?QUERY_FUN
|
||||
)
|
||||
);
|
||||
{error, _} ->
|
||||
{error, Node0, {badrpc, <<"invalid node">>}}
|
||||
end
|
||||
end,
|
||||
case Result of
|
||||
{error, page_limit_invalid} ->
|
||||
|
|
|
@ -145,13 +145,18 @@ subscriptions(get, #{query_string := QString}) ->
|
|||
?QUERY_FUN
|
||||
);
|
||||
Node0 ->
|
||||
case emqx_misc:safe_to_existing_atom(Node0) of
|
||||
{ok, Node1} ->
|
||||
emqx_mgmt_api:node_query(
|
||||
binary_to_atom(Node0, utf8),
|
||||
Node1,
|
||||
QString,
|
||||
?SUBS_QTABLE,
|
||||
?SUBS_QSCHEMA,
|
||||
?QUERY_FUN
|
||||
)
|
||||
);
|
||||
{error, _} ->
|
||||
{error, Node0, {badrpc, <<"invalid node">>}}
|
||||
end
|
||||
end,
|
||||
case Response of
|
||||
{error, page_limit_invalid} ->
|
||||
|
|
Loading…
Reference in New Issue