The sys admin's daily grind – Mosquitto
No Insect Bites
![](/var/linux_magazin/storage/images/issues/2017/198/charly-s-column-mosquitto-message-broker/kuehnast_charly_2.png/697243-1-eng-US/Kuehnast_Charly_2.png_medium.png)
Sys admin Charly does not tend toward hostilities, but he has huge problems with mosquitoes. Despite this, he does make an exception for the Mosquitto message broker.
I recently read that around 100 species become extinct every year. So why not mosquitoes? I am merciless on the issue, because I happen to be allergic to their stings. I can't sleep, with just one of these pests buzzing around my bedroom. My weapon of choice – always at hand to decimate the population of my enemy – is a 30-year-old school atlas beside the bed. But it is still a Sisyphean task.
And the bloodstains on the wallpaper also impact on the kind of atmosphere that I would like have in my bedroom, which explains why I repaper the walls nearly every year. I also failed to secure a majority vote in the family council for my suggestions of adopting mosquito-eating spiders or using a Linux and LiDAR (light detection and ranging) based mosquito laser. War is always miserable.
You will thus understand that my response to a piece of software named after these flying bloodsuckers was somewhat skeptical. However, this much I will reveal in advance, Mosquitto [1] is allowed to stay. The tool was given its name, because the developer wanted to have the letters MQTT in there somewhere, as the acronym for message queue telemetry transport. And telemetry is the right keyword for describing Mosquitto's task.
Mosquitto operates a messaging hub; in MQTT speak, this is known as the message broker. Any client wanting to communicate sends its message to the broker (publisher), and all clients that have a subscription with the broker (subscribers) then receive the message. The broker is simply named mosquitto
and runs as a daemon; the clients that publish and subscribe go by the names of mosquitto_pub
and mosquitto_sub
.
First, I start the broker. It normally runs in the background, but I can also stop the daemon and start it in the foreground on the console. Because Mosquitto runs on port 1883, I don't even need root privileges to do this:
mosquitto -v
The -v
parameter sets a higher verbosity level, so that I can send to the broker at work. Then I use the mosquitto_sub
client to subscribe to a topic. The topic is freely selectable and should ideally describe the type of data that you can expect in a meaningful way. As an example, I can subscribe to the topic date
:
mosquitto_sub -h 127.0.0.1 -i subscriber -t date
The -i
parameter describes the client's identity and is freely definable. I used subscriber
here; in a practical application, however, it would make more sense to use the client's hostname.
Mosquitto News
Time to publish something. On another console, I typed the following:
mosquitto_pub -h 127.0.0.1 -i publisher -t date -m "30.02.2017 ;-)"
See Figure 1. The text passed in with -m <text>
immediately appears on the console where mosquitto_sub
is waiting for data.
![](/var/linux_magazin/storage/images/issues/2017/198/charly-s-column-mosquitto-message-broker/figure-1/697246-1-eng-US/Figure-1_large.png)
Impressively simple, don't you think? In daily use, topics are often hierarchically organized; users separate the hierarchy levels with a slash, as in: readings/humidity/outdoor
. You can secure communication with TLS and also stipulate that the server and clients identify themselves with certificates. I must admit: Mosquitto is useful. But my atlas is still staying where it is!
Infos
- Mosquitto: https://mosquitto.org
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.