From 5d51d5553351da43827fd7bcf8dbc5281ad38364 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Thu, 13 Aug 2015 22:29:32 +0800 Subject: [PATCH 1/7] log --- src/emqttd_log.erl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/emqttd_log.erl diff --git a/src/emqttd_log.erl b/src/emqttd_log.erl new file mode 100644 index 000000000..9aafdb6d3 --- /dev/null +++ b/src/emqttd_log.erl @@ -0,0 +1,31 @@ +%%%----------------------------------------------------------------------------- +%%% Copyright (c) 2012-2015 eMQTT.IO, All Rights Reserved. +%%% +%%% Permission is hereby granted, free of charge, to any person obtaining a copy +%%% of this software and associated documentation files (the "Software"), to deal +%%% in the Software without restriction, including without limitation the rights +%%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%%% copies of the Software, and to permit persons to whom the Software is +%%% furnished to do so, subject to the following conditions: +%%% +%%% The above copyright notice and this permission notice shall be included in all +%%% copies or substantial portions of the Software. +%%% +%%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +%%% SOFTWARE. +%%%----------------------------------------------------------------------------- +%%% @doc +%%% emqttd log trace. +%%% +%%% @end +%%%----------------------------------------------------------------------------- + +%% TODO: issue #103 + +-module(emqttd_log). + From 72751e542801a6a390314a5b7f7076fe67fb3066 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Fri, 14 Aug 2015 10:53:01 +0800 Subject: [PATCH 2/7] allow dashboard to subscribe --- rel/files/acl.config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rel/files/acl.config b/rel/files/acl.config index c1985f1d4..3359b2b04 100644 --- a/rel/files/acl.config +++ b/rel/files/acl.config @@ -18,6 +18,8 @@ %% %%%----------------------------------------------------------------------------- +{allow, {user, "dashboard"}, subscribe, ["$SYS/#"]}. + {allow, {ipaddr, "127.0.0.1"}, pubsub, ["$SYS/#", "#"]}. {deny, all, subscribe, ["$SYS/#", {eq, "#"}]}. From 322f2f61f50ca772a61e8ce30b92443a5dd00e4e Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Fri, 14 Aug 2015 11:43:20 +0800 Subject: [PATCH 3/7] update plugins --- plugins/emqttd_dashboard | 2 +- plugins/emqttd_plugin_mysql | 2 +- plugins/emqttd_plugin_template | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 160000 plugins/emqttd_plugin_template diff --git a/plugins/emqttd_dashboard b/plugins/emqttd_dashboard index dd202346f..fc49f53df 160000 --- a/plugins/emqttd_dashboard +++ b/plugins/emqttd_dashboard @@ -1 +1 @@ -Subproject commit dd202346fcfce6b0ae8da76bb7233e91db996bfa +Subproject commit fc49f53dfc3f02a09353e816f32980b113c42003 diff --git a/plugins/emqttd_plugin_mysql b/plugins/emqttd_plugin_mysql index 04baf44a4..c2f32b5f2 160000 --- a/plugins/emqttd_plugin_mysql +++ b/plugins/emqttd_plugin_mysql @@ -1 +1 @@ -Subproject commit 04baf44a465c1513e75dfdcc2f6507e7a315d2d5 +Subproject commit c2f32b5f29d0b3ad7446aef1dda1c67923d27a49 diff --git a/plugins/emqttd_plugin_template b/plugins/emqttd_plugin_template new file mode 160000 index 000000000..3d5d2ccab --- /dev/null +++ b/plugins/emqttd_plugin_template @@ -0,0 +1 @@ +Subproject commit 3d5d2ccabdde2d0381bcd17c803be5e42b3fec90 From d23bf74d1e3fe927768e984a1eacad3be50209eb Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Fri, 14 Aug 2015 12:16:41 +0800 Subject: [PATCH 4/7] fix issue #244 --- src/emqttd_mqueue.erl | 15 ++++++++++----- src/emqttd_session.erl | 24 +++++++++++++----------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/emqttd_mqueue.erl b/src/emqttd_mqueue.erl index 803104c5e..398db256a 100644 --- a/src/emqttd_mqueue.erl +++ b/src/emqttd_mqueue.erl @@ -59,7 +59,8 @@ -export([new/3, name/1, is_empty/1, is_full/1, len/1, max_len/1, - in/2, out/1]). + in/2, out/1, + stats/1]). -define(LOW_WM, 0.2). @@ -72,6 +73,7 @@ high_wm = ?HIGH_WM, max_len = ?MAX_LEN, qos0 = false, + dropped = 0, alarm_fun}). -type mqueue() :: #mqueue{}. @@ -111,6 +113,9 @@ len(#mqueue{len = Len}) -> Len. max_len(#mqueue{max_len= MaxLen}) -> MaxLen. +stats(#mqueue{max_len = MaxLen, len = Len, dropped = Dropped}) -> + [{max_len, MaxLen}, {len, Len}, {dropped, Dropped}]. + %%------------------------------------------------------------------------------ %% @doc Queue one message. %% @end @@ -122,11 +127,11 @@ in(#mqtt_message{qos = ?QOS_0}, MQ = #mqueue{qos0 = false}) -> MQ; %% simply drop the oldest one if queue is full, improve later -in(Msg, MQ = #mqueue{name = Name, q = Q, len = Len, max_len = MaxLen}) +in(Msg, MQ = #mqueue{q = Q, len = Len, max_len = MaxLen, dropped = Dropped}) when Len =:= MaxLen -> - {{value, OldMsg}, Q2} = queue:out(Q), - lager:error("MQueue(~s) drop ~s", [Name, emqttd_message:format(OldMsg)]), - MQ#mqueue{q = queue:in(Msg, Q2)}; + {{value, _OldMsg}, Q2} = queue:out(Q), + %lager:error("MQueue(~s) drop ~s", [Name, emqttd_message:format(OldMsg)]), + MQ#mqueue{q = queue:in(Msg, Q2), dropped = Dropped +1}; in(Msg, MQ = #mqueue{q = Q, len = Len}) -> maybe_set_alarm(MQ#mqueue{q = queue:in(Msg, Q), len = Len + 1}). diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index 38ab89a27..a9b4b10ea 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -647,21 +647,23 @@ start_collector(Session = #session{collect_interval = Interval}) -> TRef = erlang:send_after(Interval * 1000, self(), collect_info), Session#session{collect_timer = TRef}. -info(#session{clean_sess = CleanSess, - subscriptions = Subscriptions, - inflight_queue = InflightQueue, - max_inflight = MaxInflight, - message_queue = MessageQueue, - awaiting_rel = AwaitingRel, - awaiting_ack = AwaitingAck, - awaiting_comp = AwaitingComp, - timestamp = CreatedAt}) -> - [{pid, self()}, +info(#session{clean_sess = CleanSess, + subscriptions = Subscriptions, + inflight_queue = InflightQueue, + max_inflight = MaxInflight, + message_queue = MessageQueue, + awaiting_rel = AwaitingRel, + awaiting_ack = AwaitingAck, + awaiting_comp = AwaitingComp, + timestamp = CreatedAt}) -> + Stats = emqttd_mqueue:stats(MessageQueue), + [{pid, self()}, {clean_sess, CleanSess}, {subscriptions, Subscriptions}, {max_inflight, MaxInflight}, {inflight_queue, length(InflightQueue)}, - {message_queue, emqttd_mqueue:len(MessageQueue)}, + {message_queue, proplists:get_value(len, Stats)}, + {message_dropped, proplists:get_value(dropped, Stats)}, {awaiting_rel, maps:size(AwaitingRel)}, {awaiting_ack, maps:size(AwaitingAck)}, {awaiting_comp, maps:size(AwaitingComp)}, From 893b1b5dbe6d9316b77a2aa403c0a0538247615d Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Fri, 14 Aug 2015 13:16:17 +0800 Subject: [PATCH 5/7] 0.10.0 --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 893f44160..32fd565a8 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,31 @@ emqttd is aimed to provide a solid, enterprise grade, extensible open-source MQT * Passed eclipse paho interoperability tests -## Plugins +## Modules * [emqttd_auth_clientid](https://github.com/emqtt/emqttd/wiki/Authentication) - Authentication with ClientIds -* emqttd_auth_mysql - Authentication with MySQL -* emqttd_auth_ldap - Authentication with LDAP -* emqttd_mod_autosub - Subscribe some topics automatically when client connected +* [emqttd_auth_username](https://github.com/emqtt/emqttd/wiki/Authentication) - Authentication with Username and Password +* [emqttd_auth_ldap](https://github.com/emqtt/emqttd/wiki/Authentication) - Authentication with LDAP * [emqttd_mod_presence](https://github.com/emqtt/emqttd/wiki/Presence) - Publish presence message to $SYS topics when client connected or disconnected +* emqttd_mod_autosub - Subscribe topics when client connected * [emqttd_mod_rewrite](https://github.com/emqtt/emqttd/wiki/Rewrite) - Topics rewrite like HTTP rewrite module +## Plugins + +* [emqttd_plugin_template](https://github.com/emqtt/emqttd_plugin_template) - Plugin template and demo +* [emqttd_dashboard](https://github.com/emqtt/emqttd_dashboard) -> Web Dashboard +* [emqttd_plugin_mysql](https://github.com/emqtt/emqttd_plugin_mysql) - Authentication with MySQL +* [emqttd_plugin_pgsql](https://github.com/emqtt/emqttd_plugin_pgsql) - Authentication with PostgreSQL + + +## Dashboard + +The broker released a simple web dashboard in 0.10.0 version. + +Address: http://host:18083 + + ## Design ![emqttd architecture](http://emqtt.io/static/img/Architecture.png) From eb12e769e04cf55b65f4786d293d664a79ba14dc Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Fri, 14 Aug 2015 13:18:03 +0800 Subject: [PATCH 6/7] > --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32fd565a8..feea2727d 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ emqttd is aimed to provide a solid, enterprise grade, extensible open-source MQT ## Plugins * [emqttd_plugin_template](https://github.com/emqtt/emqttd_plugin_template) - Plugin template and demo -* [emqttd_dashboard](https://github.com/emqtt/emqttd_dashboard) -> Web Dashboard +* [emqttd_dashboard](https://github.com/emqtt/emqttd_dashboard) - Web Dashboard * [emqttd_plugin_mysql](https://github.com/emqtt/emqttd_plugin_mysql) - Authentication with MySQL * [emqttd_plugin_pgsql](https://github.com/emqtt/emqttd_plugin_pgsql) - Authentication with PostgreSQL From 6d4821cfca7e18542b2829269098670b3c1af332 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Fri, 14 Aug 2015 15:46:13 +0800 Subject: [PATCH 7/7] rm emysql --- .gitmodules | 6 ------ plugins/emqttd_plugin_mysql | 1 - plugins/emysql | 1 - 3 files changed, 8 deletions(-) delete mode 160000 plugins/emqttd_plugin_mysql delete mode 160000 plugins/emysql diff --git a/.gitmodules b/.gitmodules index 4015d5e02..093a4a897 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,3 @@ [submodule "plugins/emqttd_dashboard"] path = plugins/emqttd_dashboard url = https://github.com/emqtt/emqttd_dashboard.git -[submodule "plugins/emysql"] - path = plugins/emysql - url = https://github.com/erylee/emysql.git -[submodule "plugins/emqttd_plugin_mysql"] - path = plugins/emqttd_plugin_mysql - url = https://github.com/emqtt/emqttd_plugin_mysql.git diff --git a/plugins/emqttd_plugin_mysql b/plugins/emqttd_plugin_mysql deleted file mode 160000 index c2f32b5f2..000000000 --- a/plugins/emqttd_plugin_mysql +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c2f32b5f29d0b3ad7446aef1dda1c67923d27a49 diff --git a/plugins/emysql b/plugins/emysql deleted file mode 160000 index 3305c1ad9..000000000 --- a/plugins/emysql +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3305c1ad951e091c198ae10ca852752ca598e5b0