Просмотр исходного кода

Fix Dashboard not showing data

turtled 8 лет назад
Родитель
Сommit
54534967bd
2 измененных файлов с 8 добавлено и 5 удалено
  1. 4 2
      src/emqttd_http.erl
  2. 4 3
      src/emqttd_rest_api.erl

+ 4 - 2
src/emqttd_http.erl

@@ -59,8 +59,10 @@ handle_request(Req, State) ->
 
 inner_handle_request(Req, State) ->
     Path = Req:get(path),
-    handle_request(Path, Req, State).
-
+    case Path of
+        "/api/v2/auth" -> handle_request(Path, Req, State);
+        _ -> if_authorized(Req, fun() -> handle_request(Path, Req, State) end)
+    end.
 
 handle_request("/api/v2/" ++ Url, Req, #state{dispatch = Dispatch}) ->
     Dispatch(Req, Url);

+ 4 - 3
src/emqttd_rest_api.erl

@@ -212,9 +212,10 @@ session_list('GET', Params, Node, ClientId) ->
     {ok, [{objects, [session_row(Row) || Row <- Data]}]}.
 
 session_row({ClientId, _Pid, _Persistent, Session}) ->
-    InfoKeys = [clean_sess, max_inflight, inflight_queue, message_queue,
-                message_dropped, awaiting_rel, awaiting_ack, awaiting_comp, created_at],
-     [{client_id, ClientId} | [{Key, format(Key, get_value(Key, Session))} || Key <- InfoKeys]].
+    Data = lists:append(Session, emqttd_stats:get_session_stats(ClientId)),
+    InfoKeys = [clean_sess, subscriptions, max_inflight, inflight_len, mqueue_len,
+                mqueue_dropped, awaiting_rel_len, deliver_msg,enqueue_msg, created_at],
+    [{client_id, ClientId} | [{Key, format(Key, get_value(Key, Data))} || Key <- InfoKeys]].
 
 %%--------------------------------------------------------------------------
 %% subscription