пятница, 7 октября 2016 г.

Moqsquitto MQTT Broker Setup and usage

Install Mosquitto

sudo apt-get install mosquitto mosquitto-clients python-mosquitto
 

Configuration File location

/etc/mosquitto

mosquitto.conf File contents

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/
connection_messages true
log_type all
log_dest file /var/log/mosquitto/mosquitto.log
log_dest syslog

include_dir /etc/mosquitto/conf.d
 

Create /var/log/mosquitto/mosquitto_log.sh

#!/bin/bash
# My first script
sleep 120
sudo ntpdate -s ntp.obspm.fr
mkdir -p /var/log/mosquitto
mosquitto_sub -v -t /# | xargs -d$'\n' -L1 sh -c 'date "+%D %T.%3N $0"' >> /var/log/mosquitto/mosq.log &
sudo systemctl restart homebridge



 
Change permissions chmod 777 mosquitto_log.sh

Add to start script

Add to /etc/rc.local

#Start MQTT Logging
/var/log/mosquitto/msquitto_log.sh &

Комментариев нет:

Отправить комментарий