Search code examples
mosquitto

How to monitor mosquitto server through HTTP


How to monitor mosquitto server through HTTP? I am looking something like https://my.mosquitto.server.com/health or https://my.mosquitto.server.com/info.

  • Mosquitto Server: v3
  • OS: CentOS 7
  • Mosquitto Web: Enabled

Thanks


Solution

  • You are always going to need a MQTT client to get access to the information in the $SYS topic space.

    When MQTT over Websockets is enabled you can have mosquitto serve a page that will connect to the broker with the Paho Javascript client with MQTT over Websockets. The page can subscribe to what ever topics you want.

    e.g. You can use the http_dir option to specify a directory that moquitto will server static files from. Here you could deploy a slightly modified (The modification would be to change the topic from # to %SYS/#) version of my D3 MQTT topic tree viewer (code on github).

    From the mosquitto.conf man page:

    http_dir directory

    When a listener is using the websockets protocol, it is possible to serve http data as well. Set http_dir to a directory which contains the files you wish to serve. If this option is not specified, then no normal http connections will be possible.

    Not reloaded on reload signal.