快速 MQTT 日志记录器(到系统日志)

  • Main Tool: A new C++ tool to log MQTT messages to syslog and optionally the terminal, replacing the limited mqtt-data-logger python script. It compiles without syslog support if only logging to a file or terminal.
  • Features: Logs each message on a separate thread in a thread pool for speed (thousands of messages per second with enough system resources). Handles connection failures with automatic reconnect.
  • Source and Downloads: On github. A ready-made docker image is here. Licensed under GNU AGPLv3.
  • Building: Written in C++ 17 with CMake. Requires Paho MQTT C++ library and syslog.h. On Ubuntu/Debian, install libpaho-mqttpp-dev, libpaho-mqtt-dev, build-essential, and git. Clone or download the repository and use CMake to compile.
  • Usage: Configurable with command line options or environment variables. Command line args include broker URL, topic, username, password, syslog facility, and more. Environment variables are also available. Examples given for basic usage and viewing logs.
  • rsyslog and logrotate: Configure rsyslog to save logs to /var/log/mqtt_msgs.log. Use logrotate to not delete these logs.
  • Docker: Build and run with docker build -t mqtt-logger. and docker run --env BROKER=test.mosquitto.org mqtt_logger. Or use the provided docker-compose.yml file.

In summary, this is a cross-platform tool for logging MQTT messages with various configuration options and easy deployment using Docker.

阅读 8
0 条评论