PROPHET/OS
NAME
mqttv: a vigil
SYNOPSIS
mqttv [config|selbsttest]
DESCRIPTION
A vigil: holds one MQTT line and reports /state on a timer.
mqtt is the hand tool beside it and stays what it is: mqtt pub sends one message and ends, the way ping and fetch do, and a person at a console wants exactly that. A machine does not. Over cron one reading would be a connect, a publish and a disconnect, three round trips for one number and a new session for every one of them.
What it sends and how often stands in /system/config/mqttv, and that file explains its own keys: the broker, the client name, the topic, the interval, the keep alive, the will, and one line per reading. A path on the command line is read in its place.
It is off. Its entry stands in /system/config/vigils.yaml with a minus in front of its level, so telemetry is turned on by the user and not by the machine.
Readings come out of /state, the same files the tools that show those numbers read (memory, locks, pos_irqhold, sensors, disks, numa, ptp, can, watchdog). Nothing is measured twice. A section this run may not see is left out with a word about it and never sent as a zero: a zero is a measurement, and "you may not look" is not.
Every reading goes out with QoS 0. A reading that arrives twice is two readings of one number and the collector holds the last one, so a receipt buys nothing and costs a round trip. The will goes out with QoS 1 and retain, because it is the one message of this vigil nobody may lose and the last word of a machine has to stay readable for whoever subscribes afterwards.
The keep alive is kept with a PINGREQ after half of it. A broker may drop a client that was silent for one and a half keep alives, so the sign of life belongs inside the time that was promised and not at its edge.
A line that dies is answered with a reconnect and a wait that doubles up to a minute. The supervisor only ever sees this program end when somebody stops it: a vigil that ends at every hiccup of the broker reports its own restarts instead of the machine.
mqttv selbsttest drives the whole session in ring 3 against a broker in memory, because this machine has no loopback and a program of ours cannot be the other end of a connection. The clock is turned by hand there, so a ping at half a minute and a round at the hour are driven and not waited for. What stays open is a foreign broker on a real line.
EXAMPLE
$ mqttv --help mqttv [config|selbsttest] a vigil: holds one MQTT line and reports /state on a timer what it sends and how often stands in /system/config/mqttv the broker gets a will, so a line that dies is the message