Reputation: 5271
I've been searching a few hours but couldn't find useful information. Just wondering if anyone know how to send log information by mosquitto_pub
whenever logs get updated
I use syslog-ng
I'd like to use mosquitto_pub
to publish topic and message whenever the log (/var/log/syslog
or other logs that are located in /var/log/
) get updated.
eg.
/var/log/syslog
new log Started on ttyS1.
then
mosquitto_pub -h 127.0.0.1 -t Started on ttyS1 -m "Started on ttyS1."
automatically fires
Upvotes: 2
Views: 1612
Reputation: 59608
mosquitto_pub
supports reading messages from stdin a line at a time so something like the following will work:
tail -f /var/log/syslog | mosquitto_pub -t syslog -l
This will publish each line from /var/log/syslog
to the topic syslog
Upvotes: 6