mosquitto命令说明
2016-09-12 17:35阅读:
mosquitto命令参数说明
1. -c 配置文件
从文件中加载配置参数
如果没有指定默认路径为/etc/mosquitto/mosquitto.conf
2. -d 表示以后台守护进程的形式启动
3. -p 指定监听端口 默认为1883
4. -v 监控日志 类似于在配置文件中把log_type
设置为all
mosquitto broker状态监控
客户端可以通过订阅$SYS层级的话题来监控broker的相关信息
1.$SYS/broker/bytes/received 收到的所有字节数
2.$SYS/broker/bytes/sent 发送的所有字节数
3.$SYS/broker/clients/connected 当前在线的客户端数
4.$SYS/broker/clients/expired 超时的连接数
5.$SYS/broker/clients/disconnected 断开的连接数
6.$SYS/broker/clients/maximum 最大并发连接数
7.$SYS/broker/clients/total
所有连接数(活动的和非活动的)
8.$SYS/broker/heap/current size 当前用到的内存
9.$SYS/broker/heap/maximum size 用到的最大内存
$SYS/broker/load/connections/+
The moving average of the number of CONNECT packets received
by the broker over different time intervals. The final '+' of the
hierarchy can be 1min, 5min or 15min. The value returned represents
the number of connections received in 1 minute, averaged over 1, 5
or 15 minutes.
$SYS/broker/load/bytes/received/+
The moving average of the number of bytes received by the
broker over different time intervals. The final '+' of the
hierarchy can be 1min, 5min or 15min. The value returned represents
the number of bytes received in 1 minute, averaged over 1, 5 or 15
minutes.
$SYS/broker/load/bytes/sent/+
The moving average of the number of bytes sent by the broker
over different time intervals. The final '+' of the hierarchy can
be 1min, 5min or 15min. The value returned represents the number of
bytes sent in 1 minute, averaged over 1, 5 or 15
minutes.
$SYS/broker/load/messages/received/+
The moving average of the number of all types of MQTT
messages received by the broker over different time intervals. The
final '+' of the hierarchy can be 1min, 5min or 15min. The value
returned represents the number of messages received in 1 minute,
averaged over 1, 5 or 15 minutes.
$SYS/broker/load/messages/sent/+
The moving average of the number of all types of MQTT
messages sent by the broker over different time intervals. The
final '+' of the hierarchy can be 1min, 5min or 15min. The value
returned represents the number of messages send in 1 minute,
averaged over 1, 5 or 15 minutes.
$SYS/broker/load/publish/dropped/+
The moving average of the number of publish messages dropped
by the broker over different time intervals. This shows the rate at
which durable clients that are disconnected are losing messages.
The final '+' of the hierarchy can be 1min, 5min or 15min. The
value returned represents the number of messages dropped in 1
minute, averaged over 1, 5 or 15 minutes.
$SYS/broker/load/publish/received/+
The moving average of the number of publish messages received
by the broker over different time intervals. The final '+' of the
hierarchy can be 1min, 5min or 15min. The value returned represents
the number of publish messages received in 1 minute, averaged over
1, 5 or 15 minutes.
$SYS/broker/load/publish/sent/+
The moving average of the number of publish messages sent by
the broker over different time intervals. The final '+' of the
hierarchy can be 1min, 5min or 15min. The value returned represents
the number of publish messages sent in 1 minute, averaged over 1, 5
or 15 minutes.
$SYS/broker/load/sockets/+
The moving average of the number of socket connections opened
to the broker over different time intervals. The final '+' of the
hierarchy can be 1min, 5min or 15min. The value returned represents
the number of socket connections in 1 minute, averaged over 1, 5 or
15 minutes.
$SYS/broker/messages/inflight
The number of messages with QoS>0 that are awaiting
acknowledgments.
$SYS/broker/messages/received
The total number of messages of any type received since the
broker started.
$SYS/broker/messages/sent
The total number of messages of any type sent since the
broker started.
$SYS/broker/messages/stored
The number of messages currently held in the message store.
This includes retained messages and messages queued for durable
clients.
$SYS/broker/publish/messages/dropped
The total number of publish messages that have been dropped
due to inflight/queuing limits. See the max_inflight_messages and
max_queued_messages options in mosquitto.conf(5) for more
information.
$SYS/broker/publish/messages/received
The total number of PUBLISH messages received since the
broker started.
$SYS/broker/publish/messages/sent
The total number of PUBLISH messages sent since the broker
started.
$SYS/broker/retained messages/count
The total number of retained messages active on the
broker.
$SYS/broker/subscriptions/count
The total number of subscriptions active on the
broker.
$SYS/broker/timestamp
The timestamp at which this particular build of the broker
was made. Static.
$SYS/broker/uptime
The amount of time in seconds the broker has been
online.
$SYS/broker/version
The version of the broker. Static.
Wildcard Topic Subscriptions
In addition to allowing clients to subscribe to specific
topics, mosquitto also allows the use of two wildcards in
subscriptions. + is the wildcard used to match a single level of
hierarchy. For example, for a topic of 'a/b/c/d', the following
example subscriptions will match:
a/b/c/d
+/b/c/d
a/+/c/d
a/+/+/d
+/+/+/+
The following subscriptions will not match:
a/b/c
b/+/c/d
+/+/+
The second wildcard is # and is used to match all subsequent
levels of hierarchy. With a topic of 'a/b/c/d', the following
example subscriptions will match:
a/b/c/d
#
a/#
a/b/#
a/b/c/#
+/b/c/#
The $SYS hierarchy does not match a subscription of '#'. If
you want to observe the entire $SYS hierarchy, subscribe to
$SYS/#.
Note that the wildcards must be only ever used on their own,
so a subscription of 'a/b+/c' is not valid use of a wildcard. The #
wildcard must only ever be used as the final character of a
subscription.
Bridges
Multiple brokers can be connected together with the bridging
functionality. This is useful where it is desirable to share
information between locations, but where not all of the information
needs to be shared. An example could be where a number of users are
running a broker to help record power usage and for a number of
other reasons. The power usage could be shared through bridging all
of the user brokers to a common broker, allowing the power usage of
all users to be collected and compared. The other information would
remain local to each broker.
For information on configuring bridges, see
mosquitto.conf(5).
Signals
SIGHUP
Upon receiving the SIGHUP signal, mosquitto will attempt to
reload configuration file data, assuming that the -c argument was
provided when mosquitto was started. Not all configuration
parameters can be reloaded without restarting. See
mosquitto.conf(5) for details.
SIGUSR1
Upon receiving the SIGUSR1 signal, mosquitto will write the
persistence database to disk. This signal is only acted upon if
persistence is enabled.
SIGUSR2
The SIGUSR2 signal causes mosquitto to print out the current
subscription tree, along with information about where retained
messages exist. This is intended as a testing feature only and may
be removed at any time.
Files
/etc/mosquitto/mosquitto.conf
Configuration file. See mosquitto.conf(5).
/var/lib/mosquitto/mosquitto.db
Persistent message data storage location if persist
enabled.
/etc/hosts.allow, /etc/hosts.deny