将MQTT度量发布到statsd的脚本
项目描述
正如其名所示,这是一个将MQTT度量发布到statsd的脚本。它最初是为了处理mosquitto代理的$SYS/主题中的度量而设计的,但该框架足够通用,可以使用任何MQTT主题。
安装
mqtt_statsd可以通过pypi获取,因此您只需运行
pip install -U mqtt_statsd
将mqtt_statsd安装到您的系统。如果您需要使用mqtt_statsd的开发版本,您可以克隆仓库并使用以下命令本地安装
git clone https://github.com/mtreinish/mqtt_statsd.git && pip install -e mqtt_statsd
这将使mqtt_statsd在您的Python环境中以可编辑模式安装,以便进行本地开发。
配置mqtt_statsd
在运行mqtt_statsd之前,您必须创建一个yaml配置文件,以告诉mqtt_statsd如何连接到MQTT代理和statsd。以及要订阅哪些MQTT主题以及如何用从该MQTT主题获取的数据填充statsd。例如
statsd:
hostname: localhost
# port is optional, the default is shown
port: 8125
# prefix is optional, the default is shown
prefix: mosquitto.stats
mqtt:
hostname: localhost
# port is optional, the default is shown
port: 1883
# keepalive is optional, the default is shown
keepalive: 60
# username is optional, there is no default
username: foo
# password is optional, there is no default. If username isn't set this
# is ignored
password: PASS
# qos is optional, the default is shown
qos: 0
# websocket is optional, it defaults to False
websocket: True
topics:
# You can specify as many topics as you want, and mqtt_statsd will
# listen to all of them
- $SYS/broker/messages/publish/sent:
statsd_topic: publish_messages_sent
# statsd_type is optional, the default is shown. Valid options are
# gague, counter, and timer
statsd_type: gauge
- $SYS/broker/clients/connected:
statsd_topic: connected_clients
运行mqtt_statsd
在安装和配置mqtt_statsd之后,运行它非常简单。只需调用mqtt_statsd并传入一个必选参数,即yaml配置文件的路径。例如
mqtt_statsd my_config_file.yaml
项目详情
关闭
mqtt_statsd-0.0.1.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 31bc30912f7d0cd4e19fbc1b840ba55a3a4fa8fb7b1ff1bfaaff800f59f3e517 |
|
| MD5 | f9d8e240ed0cd6c8a70473c7d9d3ad42 |
|
| BLAKE2b-256 | cb5f310e171a057a07d45ca8c00891cdd7eaf74c068651a98e6700d1cf236507 |