Monitoring via MQTT: Difference between revisions
Appearance
| Line 89: | Line 89: | ||
'''-u''' and '''-P''' specify the username and password. If the Broker doesn't require authentication, these values aren't mandatory. Else replace them with the log in information of your Broker. | '''-u''' and '''-P''' specify the username and password. If the Broker doesn't require authentication, these values aren't mandatory. Else replace them with the log in information of your Broker. | ||
Lastly, '''-t''' specifies the '''topics''' that you want to subscribe to, in this case it router/<SERIAL>/signal router/<SERIAL>/uptime. Replace '''<SERIAL>''' with your router's serial number. You can find your router's serial number in the '''Status → Device''' section of the router's WebUI. Or you can first subscribe to the topic '''router/id''' and | Lastly, '''-t''' specifies the '''topics''' that you want to subscribe to, in this case it router/<SERIAL>/signal router/<SERIAL>/uptime. Replace '''<SERIAL>''' with your router's serial number. You can find your router's serial number in the '''Status → Device''' section of the router's WebUI. Or you can first subscribe to the topic '''router/id''' and publish the message '''id''' to the topic '''router/get'''. The full command would look like this: | ||
$ mosquitto_sub -h 192.168.1.1 -p 1833 -u user -P pass -t router/id | |||
To publish a message asking the router for it's serial number, or '''id''', use this command: | |||
$ mosquitto_pub -h 192.168.1.1 -p 1833 -u user -P pass -t router/get -m id | |||
The '''mosquitto_pub''' command is used to publish messages to specified topics. '''-m''' defines the message that you're publishing. Again, replace the values given with the ones in your configuration. The whole exchange is presented in the picture below: | |||
[[Image:Configuration examples mqtt router id.png]] | |||