guide.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. .. _guide:
  2. ==========
  3. User Guide
  4. ==========
  5. --------------
  6. Authentication
  7. --------------
  8. The emqttd broker supports to authenticate MQTT clients with ClientID, Username/Password, IpAddress and even HTTP Cookies.
  9. The authentication is provided by a list of extended modules, or MySQL, PostgreSQL and Redis Plugins.
  10. Enable an authentication module in etc/emqttd.config::
  11. %% Authentication and Authorization
  12. {access, [
  13. %% Authetication. Anonymous Default
  14. {auth, [
  15. %% Authentication with username, password
  16. %{username, []},
  17. %% Authentication with clientid
  18. %{clientid, [{password, no}, {file, "etc/clients.config"}]},
  19. %% Authentication with LDAP
  20. % {ldap, [
  21. % {servers, ["localhost"]},
  22. % {port, 389},
  23. % {timeout, 30},
  24. % {user_dn, "uid=$u,ou=People,dc=example,dc=com"},
  25. % {ssl, fasle},
  26. % {sslopts, [
  27. % {"certfile", "ssl.crt"},
  28. % {"keyfile", "ssl.key"}]}
  29. % ]},
  30. %% Allow all
  31. {anonymous, []}
  32. ]},
  33. .. NOTE:: "%" comments the line.
  34. If we enable several modules at the same time, the authentication process::
  35. ---------------- ---------------- -------------
  36. Client --> | Username | -ignore-> | ClientID | -ignore-> | Anonymous |
  37. ---------------- ---------------- -------------
  38. | | |
  39. \|/ \|/ \|/
  40. allow | deny allow | deny allow | deny
  41. The authentication plugins developed by emqttd:
  42. +---------------------------+---------------------------+
  43. | Plugin | Description |
  44. +===========================+===========================+
  45. | `emqttd_plugin_mysql`_ | MySQL Auth/ACL Plugin |
  46. +---------------------------+---------------------------+
  47. | `emqttd_plugin_pgsql`_ | PostgreSQL Auth/ACL Plugin|
  48. +---------------------------+---------------------------+
  49. | `emqttd_plugin_redis`_ | Redis Auth/ACL Plugin |
  50. +---------------------------+---------------------------+
  51. .. NOTE:: If we load an authentication plugin, the authentication modules will be disabled.
  52. Username
  53. --------
  54. Authenticate MQTT client with Username/Password::
  55. {username, [{client1, "passwd1"}, {client1, "passwd2"}]},
  56. Two ways to add users:
  57. 1. Configure username and plain password directly::
  58. {username, [{client1, "passwd1"}, {client1, "passwd2"}]},
  59. 2. Add user by './bin/emqttd_ctl users' command::
  60. $ ./bin/emqttd_ctl users add <Username> <Password>
  61. ClientId
  62. --------
  63. .. code:: erlang
  64. {clientid, [{password, no}, {file, "etc/clients.config"}]},
  65. Configure ClientIDs in etc/clients.config::
  66. testclientid0
  67. testclientid1 127.0.0.1
  68. testclientid2 192.168.0.1/24
  69. LDAP
  70. ----
  71. .. code:: erlang
  72. {ldap, [
  73. {servers, ["localhost"]},
  74. {port, 389},
  75. {timeout, 30},
  76. {user_dn, "uid=$u,ou=People,dc=example,dc=com"},
  77. {ssl, fasle},
  78. {sslopts, [
  79. {"certfile", "ssl.crt"},
  80. {"keyfile", "ssl.key"}]}
  81. ]},
  82. Anonymous
  83. ---------
  84. Allow any client to connect to the broker::
  85. {anonymous, []}
  86. MySQL
  87. -----
  88. Authenticate against MySQL database. Support we create a mqtt_user table::
  89. CREATE TABLE `mqtt_user` (
  90. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  91. `username` varchar(100) DEFAULT NULL,
  92. `password` varchar(100) DEFAULT NULL,
  93. `salt` varchar(20) DEFAULT NULL,
  94. `created` datetime DEFAULT NULL,
  95. PRIMARY KEY (`id`),
  96. UNIQUE KEY `mqtt_username` (`username`)
  97. ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  98. Configure the 'authquery' and 'password_hash' in emqttd_plugin_mysql/etc/plugin.config::
  99. [
  100. {emqttd_plugin_mysql, [
  101. ...
  102. %% select password only
  103. {authquery, "select password from mqtt_user where username = '%u' limit 1"},
  104. %% hash algorithm: md5, sha, sha256, pbkdf2?
  105. {password_hash, sha256},
  106. ...
  107. ]}
  108. ].
  109. Load the plugin::
  110. ./bin/emqttd_ctl plugins load emqttd_plugin_mysql
  111. PostgreSQL
  112. ----------
  113. Authenticate against PostgreSQL database. Create a mqtt_user table::
  114. CREATE TABLE mqtt_user (
  115. id SERIAL primary key,
  116. username character varying(100),
  117. password character varying(100),
  118. salt character varying(40)
  119. );
  120. Configure the 'authquery' and 'password_hash' in emqttd_plugin_pgsql/etc/plugin.config::
  121. [
  122. {emqttd_plugin_pgsql, [
  123. ...
  124. %% select password only
  125. {authquery, "select password from mqtt_user where username = '%u' limit 1"},
  126. %% hash algorithm: md5, sha, sha256, pbkdf2?
  127. {password_hash, sha256},
  128. ...
  129. ]}
  130. ].
  131. Load the plugin::
  132. ./bin/emqttd_ctl plugins load emqttd_plugin_pgsql
  133. Redis
  134. -----
  135. Authenticate against Redis. MQTT users could be stored in redis HASH, the key is "mqtt_user:<Username>".
  136. Configure 'authcmd' and 'password_hash' in emqttd_plugin_redis/etc/plugin.config::
  137. [
  138. {emqttd_plugin_redis, [
  139. ...
  140. %% HMGET mqtt_user:%u password
  141. {authcmd, ["HGET", "mqtt_user:%u", "password"]},
  142. %% Password hash algorithm: plain, md5, sha, sha256, pbkdf2?
  143. {password_hash, sha256},
  144. ...
  145. ]}
  146. ].
  147. Load the plugin::
  148. ./bin/emqttd_ctl plugins load emqttd_plugin_redis
  149. ---
  150. ACL
  151. ---
  152. The ACL of emqttd broker is responsbile for authorizing MQTT clients to publish/subscribe topics.
  153. The ACL rules define::
  154. Allow|Deny Who Publish|Subscribe Topics
  155. Access Control Module of emqttd broker will match the rules one by one::
  156. --------- --------- ---------
  157. Client -> | Rule1 | --nomatch--> | Rule2 | --nomatch--> | Rule3 | --> Default
  158. --------- --------- ---------
  159. | | |
  160. match match match
  161. \|/ \|/ \|/
  162. allow | deny allow | deny allow | deny
  163. Internal
  164. --------
  165. The default ACL of emqttd broker is implemented by an 'internal' module.
  166. Enable the 'internal' ACL module in etc/emqttd.config::
  167. {acl, [
  168. %% Internal ACL module
  169. {internal, [{file, "etc/acl.config"}, {nomatch, allow}]}
  170. ]}
  171. The ACL rules of 'internal' module are defined in 'etc/acl.config' file::
  172. %% Allow 'dashboard' to subscribe '$SYS/#'
  173. {allow, {user, "dashboard"}, subscribe, ["$SYS/#"]}.
  174. %% Allow clients from localhost to subscribe any topics
  175. {allow, {ipaddr, "127.0.0.1"}, pubsub, ["$SYS/#", "#"]}.
  176. %% Deny clients to subscribe '$SYS#' and '#'
  177. {deny, all, subscribe, ["$SYS/#", {eq, "#"}]}.
  178. %% Allow all by default
  179. {allow, all}.
  180. MySQL
  181. -----
  182. ACL against MySQL database. The mqtt_acl table and default data::
  183. CREATE TABLE `mqtt_acl` (
  184. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  185. `allow` int(1) DEFAULT NULL COMMENT '0: deny, 1: allow',
  186. `ipaddr` varchar(60) DEFAULT NULL COMMENT 'IpAddress',
  187. `username` varchar(100) DEFAULT NULL COMMENT 'Username',
  188. `clientid` varchar(100) DEFAULT NULL COMMENT 'ClientId',
  189. `access` int(2) NOT NULL COMMENT '1: subscribe, 2: publish, 3: pubsub',
  190. `topic` varchar(100) NOT NULL DEFAULT '' COMMENT 'Topic Filter',
  191. PRIMARY KEY (`id`)
  192. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  193. INSERT INTO mqtt_acl (id, allow, ipaddr, username, clientid, access, topic)
  194. VALUES
  195. (1,1,NULL,'$all',NULL,2,'#'),
  196. (2,0,NULL,'$all',NULL,1,'$SYS/#'),
  197. (3,0,NULL,'$all',NULL,1,'eq #'),
  198. (5,1,'127.0.0.1',NULL,NULL,2,'$SYS/#'),
  199. (6,1,'127.0.0.1',NULL,NULL,2,'#'),
  200. (7,1,NULL,'dashboard',NULL,1,'$SYS/#');
  201. Configure 'aclquery' and 'acl_nomatch' in emqttd_plugin_mysql/etc/plugin.config::
  202. [
  203. {emqttd_plugin_mysql, [
  204. ...
  205. %% comment this query, the acl will be disabled
  206. {aclquery, "select * from mqtt_acl where ipaddr = '%a' or username = '%u' or username = '$all' or clientid = '%c'"},
  207. %% If no rules matched, return...
  208. {acl_nomatch, allow}
  209. ]}
  210. ].
  211. PostgreSQL
  212. ----------
  213. ACL against PostgreSQL database. The mqtt_acl table and default data::
  214. CREATE TABLE mqtt_acl (
  215. id SERIAL primary key,
  216. allow integer,
  217. ipaddr character varying(60),
  218. username character varying(100),
  219. clientid character varying(100),
  220. access integer,
  221. topic character varying(100)
  222. );
  223. INSERT INTO mqtt_acl (id, allow, ipaddr, username, clientid, access, topic)
  224. VALUES
  225. (1,1,NULL,'$all',NULL,2,'#'),
  226. (2,0,NULL,'$all',NULL,1,'$SYS/#'),
  227. (3,0,NULL,'$all',NULL,1,'eq #'),
  228. (5,1,'127.0.0.1',NULL,NULL,2,'$SYS/#'),
  229. (6,1,'127.0.0.1',NULL,NULL,2,'#'),
  230. (7,1,NULL,'dashboard',NULL,1,'$SYS/#');
  231. Configure 'aclquery' and 'acl_nomatch' in emqttd_plugin_pgsql/etc/plugin.config::
  232. [
  233. {emqttd_plugin_pgsql, [
  234. ...
  235. %% Comment this query, the acl will be disabled. Notice: don't edit this query!
  236. {aclquery, "select allow, ipaddr, username, clientid, access, topic from mqtt_acl
  237. where ipaddr = '%a' or username = '%u' or username = '$all' or clientid = '%c'"},
  238. %% If no rules matched, return...
  239. {acl_nomatch, allow}
  240. ...
  241. ]}
  242. ].
  243. Redis
  244. -----
  245. ACL against Redis. We store ACL rules for each MQTT client in a Redis List by defualt. The key is "mqtt_acl:<Username>", the value is a list of "publish <Topic>", "subscribe <Topic>" or "pubsub <Topic>".
  246. Configure 'aclcmd' and 'acl_nomatch' in emqttd_plugin_redis/etc/plugin.config::
  247. [
  248. {emqttd_plugin_redis, [
  249. ...
  250. %% SMEMBERS mqtt_acl:%u
  251. {aclcmd, ["SMEMBERS", "mqtt_acl:%u"]},
  252. %% If no rules matched, return...
  253. {acl_nomatch, deny},
  254. ...
  255. ]}
  256. ].
  257. ----------------------
  258. MQTT Publish/Subscribe
  259. ----------------------
  260. MQTT is a an extremely lightweight publish/subscribe messaging protocol desgined for IoT, M2M and Mobile applications.
  261. .. image:: _static/images/pubsub_concept.png
  262. Install and start the emqttd broker, and then any MQTT client could connect to the broker, subscribe topics and publish messages.
  263. MQTT Client Libraries: https://github.com/mqtt/mqtt.github.io/wiki/libraries
  264. For example, we use mosquitto_sub/pub commands::
  265. mosquitto_sub -t topic -q 2
  266. mosquitto_pub -t topic -q 1 -m "Hello, MQTT!"
  267. MQTT V3.1.1 Protocol Specification: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
  268. MQTT Listener of emqttd broker is configured in etc/emqttd.config::
  269. {mqtt, 1883, [
  270. %% Size of acceptor pool
  271. {acceptors, 16},
  272. %% Maximum number of concurrent clients
  273. {max_clients, 512},
  274. %% Socket Access Control
  275. {access, [{allow, all}]},
  276. %% Connection Options
  277. {connopts, [
  278. %% Rate Limit. Format is 'burst, rate', Unit is KB/Sec
  279. %% {rate_limit, "100,10"} %% 100K burst, 10K rate
  280. ]},
  281. %% Socket Options
  282. {sockopts, [
  283. %Set buffer if hight thoughtput
  284. %{recbuf, 4096},
  285. %{sndbuf, 4096},
  286. %{buffer, 4096},
  287. %{nodelay, true},
  288. {backlog, 512}
  289. ]}
  290. ]},
  291. MQTT(SSL) Listener, Default Port is 8883::
  292. {mqtts, 8883, [
  293. %% Size of acceptor pool
  294. {acceptors, 4},
  295. %% Maximum number of concurrent clients
  296. {max_clients, 512},
  297. %% Socket Access Control
  298. {access, [{allow, all}]},
  299. %% SSL certificate and key files
  300. {ssl, [{certfile, "etc/ssl/ssl.crt"},
  301. {keyfile, "etc/ssl/ssl.key"}]},
  302. %% Socket Options
  303. {sockopts, [
  304. {backlog, 1024}
  305. %{buffer, 4096},
  306. ]}
  307. ]},
  308. ----------------
  309. HTTP Publish API
  310. ----------------
  311. The emqttd broker provides a HTTP API to help application servers publish messages to MQTT clients.
  312. HTTP API: POST http://host:8083/mqtt/publish
  313. Web servers such as PHP, Java, Python, NodeJS and Ruby on Rails could use HTTP POST to publish MQTT messages to the broker::
  314. curl -v --basic -u user:passwd -d "qos=1&retain=0&topic=/a/b/c&message=hello from http..." -k http://localhost:8083/mqtt/publish
  315. Parameters of the HTTP API:
  316. +---------+----------------+
  317. | Name | Description |
  318. +=========+================+
  319. | client | clientid |
  320. +---------+----------------+
  321. | qos | QoS(0, 1, 2) |
  322. +---------+----------------+
  323. | retain | Retain(0, 1) |
  324. +---------+----------------+
  325. | topic | Topic |
  326. +---------+----------------+
  327. | message | Payload |
  328. +---------+----------------+
  329. .. NOTE:: The API uses HTTP Basic Authentication.
  330. -------------------
  331. MQTT Over WebSocket
  332. -------------------
  333. Web browsers could connect to the emqttd broker directly by MQTT Over WebSocket.
  334. +-------------------------+----------------------------+
  335. | WebSocket URI: | ws(s)://host:8083/mqtt |
  336. +-------------------------+----------------------------+
  337. | Sec-WebSocket-Protocol: | 'mqttv3.1' or 'mqttv3.1.1' |
  338. +-------------------------+----------------------------+
  339. The Dashboard plugin provides a test page for WebSocket::
  340. http://127.0.0.1:18083/websocket.html
  341. Listener of WebSocket and HTTP Publish API is configured in etc/emqttd.config::
  342. %% HTTP and WebSocket Listener
  343. {http, 8083, [
  344. %% Size of acceptor pool
  345. {acceptors, 4},
  346. %% Maximum number of concurrent clients
  347. {max_clients, 64},
  348. %% Socket Access Control
  349. {access, [{allow, all}]},
  350. %% Socket Options
  351. {sockopts, [
  352. {backlog, 1024}
  353. %{buffer, 4096},
  354. ]}
  355. ]}
  356. -----------
  357. $SYS Topics
  358. -----------
  359. The emqttd broker periodically publishes internal status, MQTT statistics, metrics and client online/offline status to $SYS/# topics.
  360. For emqttd broker is clustered, the $SYS topic path is started with::
  361. $SYS/brokers/${node}/
  362. '${node}' is the erlang node name of emqttd broker. For example::
  363. $SYS/brokers/emqttd@127.0.0.1/version
  364. $SYS/brokers/emqttd@host2/uptime
  365. .. NOTE:: The broker only allows clients from localhost to subscribe $SYS topics by default.
  366. Sys Interval of publishing $SYS messages, could be configured in etc/emqttd.config::
  367. {broker, [
  368. %% System interval of publishing broker $SYS messages
  369. {sys_interval, 60},
  370. Broker Version, Uptime and Description
  371. ---------------------------------------
  372. +--------------------------------+-----------------------+
  373. | Topic | Description |
  374. +================================+=======================+
  375. | $SYS/brokers | Broker nodes |
  376. +--------------------------------+-----------------------+
  377. | $SYS/brokers/${node}/version | Broker Version |
  378. +--------------------------------+-----------------------+
  379. | $SYS/brokers/${node}/uptime | Broker Uptime |
  380. +--------------------------------+-----------------------+
  381. | $SYS/brokers/${node}/datetime | Broker DateTime |
  382. +--------------------------------+-----------------------+
  383. | $SYS/brokers/${node}/sysdescr | Broker Description |
  384. +--------------------------------+-----------------------+
  385. Online/Offline Status of MQTT Client
  386. ------------------------------------
  387. The topic path started with: $SYS/brokers/${node}/clients/
  388. +--------------------------+--------------------------------------------+------------------------------------+
  389. | Topic | Payload(JSON) | Description |
  390. +==========================+============================================+====================================+
  391. | ${clientid}/connected | {ipaddress: "127.0.0.1", username: "test", | Publish when a client connected |
  392. | | session: false, version: 3, connack: 0, | |
  393. | | ts: 1432648482} | |
  394. +--------------------------+--------------------------------------------+------------------------------------+
  395. | ${clientid}/disconnected | {reason: "keepalive_timeout", | Publish when a client disconnected |
  396. | | ts: 1432749431} | |
  397. +--------------------------+--------------------------------------------+------------------------------------+
  398. Properties of 'connected' Payload::
  399. ipaddress: "127.0.0.1",
  400. username: "test",
  401. session: false,
  402. protocol: 3,
  403. connack: 0,
  404. ts: 1432648482
  405. Properties of 'disconnected' Payload::
  406. reason: normal,
  407. ts: 1432648486
  408. Broker Statistics
  409. -----------------
  410. Topic path started with: $SYS/brokers/${node}/stats/
  411. Clients
  412. .......
  413. +---------------------+---------------------------------------------+
  414. | Topic | Description |
  415. +---------------------+---------------------------------------------+
  416. | clients/count | Count of current connected clients |
  417. +---------------------+---------------------------------------------+
  418. | clients/max | Max number of cocurrent connected clients |
  419. +---------------------+---------------------------------------------+
  420. Sessions
  421. ........
  422. +---------------------+---------------------------------------------+
  423. | Topic | Description |
  424. +---------------------+---------------------------------------------+
  425. | sessions/count | Count of current sessions |
  426. +---------------------+---------------------------------------------+
  427. | sessions/max | Max number of sessions |
  428. +---------------------+---------------------------------------------+
  429. Subscriptions
  430. .............
  431. +---------------------+---------------------------------------------+
  432. | Topic | Description |
  433. +---------------------+---------------------------------------------+
  434. | subscriptions/count | Count of current subscriptions |
  435. +---------------------+---------------------------------------------+
  436. | subscriptions/max | Max number of subscriptions |
  437. +---------------------+---------------------------------------------+
  438. Topics
  439. ......
  440. +---------------------+---------------------------------------------+
  441. | Topic | Description |
  442. +---------------------+---------------------------------------------+
  443. | topics/count | Count of current topics |
  444. +---------------------+---------------------------------------------+
  445. | topics/max | Max number of topics |
  446. +---------------------+---------------------------------------------+
  447. Broker Metrics
  448. --------------
  449. Topic path started with: $SYS/brokers/${node}/metrics/
  450. Bytes Sent/Received
  451. ...................
  452. +---------------------+---------------------------------------------+
  453. | Topic | Description |
  454. +---------------------+---------------------------------------------+
  455. | bytes/received | MQTT Bytes Received since broker started |
  456. +---------------------+---------------------------------------------+
  457. | bytes/sent | MQTT Bytes Sent since the broker started |
  458. +---------------------+---------------------------------------------+
  459. Packets Sent/Received
  460. .....................
  461. +--------------------------+---------------------------------------------+
  462. | Topic | Description |
  463. +--------------------------+---------------------------------------------+
  464. | packets/received | MQTT Packets received |
  465. +--------------------------+---------------------------------------------+
  466. | packets/sent | MQTT Packets sent |
  467. +--------------------------+---------------------------------------------+
  468. | packets/connect | MQTT CONNECT Packet received |
  469. +--------------------------+---------------------------------------------+
  470. | packets/connack | MQTT CONNACK Packet sent |
  471. +--------------------------+---------------------------------------------+
  472. | packets/publish/received | MQTT PUBLISH packets received |
  473. +--------------------------+---------------------------------------------+
  474. | packets/publish/sent | MQTT PUBLISH packets sent |
  475. +--------------------------+---------------------------------------------+
  476. | packets/subscribe | MQTT SUBSCRIBE Packets received |
  477. +--------------------------+---------------------------------------------+
  478. | packets/suback | MQTT SUBACK packets sent |
  479. +--------------------------+---------------------------------------------+
  480. | packets/unsubscribe | MQTT UNSUBSCRIBE Packets received |
  481. +--------------------------+---------------------------------------------+
  482. | packets/unsuback | MQTT UNSUBACK Packets sent |
  483. +--------------------------+---------------------------------------------+
  484. | packets/pingreq | MQTT PINGREQ packets received |
  485. +--------------------------+---------------------------------------------+
  486. | packets/pingresp | MQTT PINGRESP Packets sent |
  487. +--------------------------+---------------------------------------------+
  488. | packets/disconnect | MQTT DISCONNECT Packets received |
  489. +--------------------------+---------------------------------------------+
  490. Messages Sent/Received
  491. ......................
  492. +--------------------------+---------------------------------------------+
  493. | Topic | Description |
  494. +--------------------------+---------------------------------------------+
  495. | messages/received | Messages Received |
  496. +--------------------------+---------------------------------------------+
  497. | messages/sent | Messages Sent |
  498. +--------------------------+---------------------------------------------+
  499. | messages/retained | Messages Retained |
  500. +--------------------------+---------------------------------------------+
  501. | messages/stored | TODO: Messages Stored |
  502. +--------------------------+---------------------------------------------+
  503. | messages/dropped | Messages Dropped |
  504. +--------------------------+---------------------------------------------+
  505. Broker Alarms
  506. -------------
  507. Topic path started with: $SYS/brokers/${node}/alarms/
  508. +------------------+------------------+
  509. | Topic | Description |
  510. +------------------+------------------+
  511. | ${alarmId}/alert | New Alarm |
  512. +------------------+------------------+
  513. | ${alarmId}/clear | Clear Alarm |
  514. +------------------+------------------+
  515. Broker Sysmon
  516. -------------
  517. Topic path started with: '$SYS/brokers/${node}/sysmon/'
  518. +------------------+--------------------+
  519. | Topic | Description |
  520. +------------------+--------------------+
  521. | long_gc | Long GC Warning |
  522. +------------------+--------------------+
  523. | long_schedule | Long Schedule |
  524. +------------------+--------------------+
  525. | large_heap | Large Heap Warning |
  526. +------------------+--------------------+
  527. | busy_port | Busy Port Warning |
  528. +------------------+--------------------+
  529. | busy_dist_port | Busy Dist Port |
  530. +------------------+--------------------+
  531. -----
  532. Trace
  533. -----
  534. The emqttd broker supports to trace MQTT packets received/sent from/to a client, or trace MQTT messages published to a topic.
  535. Trace a client::
  536. ./bin/emqttd_ctl trace client "clientid" "trace_clientid.log"
  537. Trace a topic::
  538. ./bin/emqttd_ctl trace topic "topic" "trace_topic.log"
  539. Lookup Traces::
  540. ./bin/emqttd_ctl trace list
  541. Stop a Trace::
  542. ./bin/emqttd_ctl trace client "clientid" off
  543. ./bin/emqttd_ctl trace topic "topic" off
  544. .. _emqttd_plugin_mysql: https://github.com/emqtt/emqttd_plugin_mysql
  545. .. _emqttd_plugin_pgsql: https://github.com/emqtt/emqttd_plugin_pgsql
  546. .. _emqttd_plugin_redis: https://github.com/emqtt/emqttd_plugin_redis