Skip to content

Instantly share code, notes, and snippets.

@mouldybread
mouldybread / gist:dbd47313f1c197c2d6f22471fa5fbcbd
Last active March 7, 2025 22:49
This Python script collects time synchronization statistics from the Chrony daemon using the chronyc command-line tool and publishes these stats to an MQTT broker. Daemonises itself and collects data every 60 seconds, log output send to syslog. Requires python-daemon.
import subprocess
import paho.mqtt.client as mqtt
import json
import logging
import time
import daemon
import signal
from logging.handlers import SysLogHandler
# MQTT configuration
@mouldybread
mouldybread / gist:b1bf8f6bcd047192b21fa78e08a9e6c5
Last active March 4, 2025 18:29
A python script to read the serial output from a Bosean FS-5000 Radiation Detector and send that information to an MQTT server. Based on the fs5000.py script shared by Tim Brooks / brookst.
#!/usr/bin/env python3
# Original script by Tim Brooks
# https://gist.github.com/brookst/bdbede3a8d40eb8940a5b53e7ca1f6ce
# Disclaimer: I can't write python! I wanted to do this but couldn't find another way, so I asked an AI to modify the original script.
# It should run silently unless there is an error, and MQTT messages are only sent when a value changes.
# However I am not in a position to gauge the quality of the script.
import datetime