<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Logging on tsvinc</title>
		<link>https://tsvinc.dev/tags/logging/</link>
		<description>Recent content in Logging on tsvinc</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Mon, 02 Nov 2026 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://tsvinc.dev/tags/logging/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Record MQTT topics to a MikroTik router&#39;s SSD</title>
				<link>https://tsvinc.dev/guides/mqtt-recorder-routeros-container/</link>
				<pubDate>Mon, 02 Nov 2026 00:00:00 +0000</pubDate>
				<guid>https://tsvinc.dev/guides/mqtt-recorder-routeros-container/</guid>
				<description>&lt;p&gt;This runs &lt;code&gt;mosquitto_sub&lt;/code&gt; in a RouterOS 7.24 container and appends every message on a set of MQTT topics to a file on the router&#39;s SSD, one file per UTC day, with a timestamp on each line.&lt;/p&gt;&#xA;&#xA;&lt;dl class=&#34;guide-scope&#34;&gt;&lt;div class=&#34;guide-scope-row&#34;&gt;&lt;dt&gt;Tested on&lt;/dt&gt;&lt;dd&gt;a MikroTik router with RouterOS 7.24, the container package and a USB SSD (&lt;code&gt;usb1-part1&lt;/code&gt;), image &lt;code&gt;eclipse-mosquitto:2.1.2-alpine&lt;/code&gt; pulled from Docker Hub, broker in another container on the same container bridge (2026-11-02). The stop-signal behaviour of &lt;code&gt;run.sh&lt;/code&gt; was re-checked in Docker 29.9.2 on Fedora 44 the same day.&lt;/dd&gt;&lt;/div&gt;&lt;div class=&#34;guide-scope-row is-gap&#34;&gt;&lt;dt&gt;Not verified&lt;/dt&gt;&lt;dd&gt;the rollback; the day switch of the file name (the recorder has run for less than a day); this exact order (my first deploy named another container&#39;s envlist, and I moved the running container to &lt;code&gt;mqttrec&lt;/code&gt; later the same day); and the commands of steps 1, 3 and 6 as written here: my notes record what each step did, not these exact lines.&lt;/dd&gt;&lt;/div&gt;&lt;div class=&#34;guide-scope-row&#34;&gt;&lt;dt&gt;Needs&lt;/dt&gt;&lt;dd&gt;a container bridge with a gateway address on the router and an MQTT broker reachable from it; the router&#39;s container registry set to Docker Hub; a read-only MQTT user; SSH and SCP to the router; an external disk with free space.&lt;/dd&gt;&lt;/div&gt;&lt;div class=&#34;guide-scope-row&#34;&gt;&lt;dt&gt;Time&lt;/dt&gt;&lt;dd&gt;20 min plus the image pull.&lt;/dd&gt;&lt;/div&gt;&lt;div class=&#34;guide-scope-row&#34;&gt;&lt;dt&gt;Risk&lt;/dt&gt;&lt;dd&gt;low. The container only opens an outbound MQTT connection and writes to one directory. Nothing rotates or deletes the files: about 3.5 to 5 MB a day, so a large SSD lasts decades, a small USB stick does not. Rollback removes one container, one mount, one envlist, one bridge port and one veth.&lt;/dd&gt;&lt;/div&gt;&lt;/dl&gt;&#xA;&lt;h2 id=&#34;before-you-start&#34;&gt;Before you start&lt;a class=&#34;heading-anchor&#34; href=&#34;#before-you-start&#34; aria-label=&#34;Link to section: Before you start&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Placeholders used below:&lt;/p&gt;&#xA;&lt;div class=&#34;table-wrap&#34; aria-label=&#34;Table: Placeholder, Meaning (mine)&#34;&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;Placeholder&lt;/th&gt;&#xA;      &lt;th&gt;Meaning (mine)&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;&amp;lt;ROUTER&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;SSH &lt;code&gt;user@address&lt;/code&gt; of the router, plus your own &lt;code&gt;-i &amp;lt;KEY&amp;gt;&lt;/code&gt; options&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;&amp;lt;DISK&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;the external disk (&lt;code&gt;usb1-part1&lt;/code&gt;)&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;&amp;lt;CT_BRIDGE&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;the bridge your containers&#39; veths are ports of (&lt;code&gt;bridge-containers&lt;/code&gt;)&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;&amp;lt;CT_ADDR&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;CT_GW&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;a free address on that bridge for the recorder, and the bridge&#39;s gateway (&lt;code&gt;172.17.0.5&lt;/code&gt;, &lt;code&gt;172.17.0.1&lt;/code&gt;)&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;&amp;lt;BROKER_IP&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;the broker&#39;s address as seen from the container bridge (&lt;code&gt;172.17.0.3&lt;/code&gt;)&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;&amp;lt;MQTT_USER&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;MQTT_PASSWORD&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;the read-only MQTT login the recorder uses&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The registry is Docker Hub. &lt;code&gt;remote-image&lt;/code&gt; pulls from the registry set in &lt;code&gt;/container/config&lt;/code&gt;, and MikroTik&#39;s documented default is &lt;code&gt;https://lscr.io/&lt;/code&gt;. Check &lt;code&gt;registry-url&lt;/code&gt; in &lt;code&gt;ssh &amp;lt;ROUTER&amp;gt; &#39;/container/config/print&#39;&lt;/code&gt;; if it isn&#39;t Docker Hub, set it as MikroTik&#39;s page shows: &lt;code&gt;/container/config/set registry-url=https://registry-1.docker.io&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The broker accepts the read-only user and lets it subscribe to the topics you put into &lt;code&gt;run.sh&lt;/code&gt; in step 2.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;strong&gt;Backup:&lt;/strong&gt; take a config export before step 1 (&lt;code&gt;/export file=&amp;lt;DISK&amp;gt;/backups/&amp;lt;NAME&amp;gt;&lt;/code&gt;) and copy it off the router.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
	</channel>
</rss>
