From 93d362bcc94a65e38d1410b95c6f6571be00c27a Mon Sep 17 00:00:00 2001 From: kx1t Date: Tue, 28 Mar 2023 16:01:27 -0400 Subject: [PATCH] add readsb-prometheus data --- rootfs/etc/cont-finish.d/02-remove-prometheus-data | 4 ++++ rootfs/etc/services.d/prometheus-readsb/run | 12 ++++++++++++ rootfs/etc/services.d/readsb/run | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 rootfs/etc/cont-finish.d/02-remove-prometheus-data create mode 100644 rootfs/etc/services.d/prometheus-readsb/run diff --git a/rootfs/etc/cont-finish.d/02-remove-prometheus-data b/rootfs/etc/cont-finish.d/02-remove-prometheus-data new file mode 100644 index 0000000..3def684 --- /dev/null +++ b/rootfs/etc/cont-finish.d/02-remove-prometheus-data @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash +#shellcheck shell=bash + +rm -f /run/readsb-prometheus.prom || true diff --git a/rootfs/etc/services.d/prometheus-readsb/run b/rootfs/etc/services.d/prometheus-readsb/run new file mode 100644 index 0000000..6e0a5b7 --- /dev/null +++ b/rootfs/etc/services.d/prometheus-readsb/run @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bash +#shellcheck shell=bash + +if [[ -n "$PROMETHEUS_ENABLE" ]]; then + while [[ ! -f /run/readsb-prometheus.prom ]] + do + sleep 1 + done + echo -e "HTTP/1.1 200 OK\nContent-Type: text/plain\n\n$(cat /run/readsb-prometheus.prom)" | ncat -l 9274 > /dev/null 2>&1 +else + sleep infinity +fi diff --git a/rootfs/etc/services.d/readsb/run b/rootfs/etc/services.d/readsb/run index a30cf06..07398f8 100644 --- a/rootfs/etc/services.d/readsb/run +++ b/rootfs/etc/services.d/readsb/run @@ -314,6 +314,14 @@ if [[ -n "$READSB_BEAST_BAUDRATE" ]]; then READSB_CMD+=("--beast-baudrate=$READSB_BEAST_BAUDRATE") fi +##################### +# Handle --write-prom= + +if [[ -n "$PROMETHEUS_ENABLE" ]]; then + READSB_CMD+=("--write-prom=/run/readsb-prometheus.prom") +fi + + # shellcheck disable=SC2086 if [[ -z "${LOGLEVEL}" ]] || [[ "${LOGLEVEL,,}" == "verbose" ]]; then "${READSB_BIN}" "${READSB_CMD[@]}" $READSB_EXTRA_ARGS 2>&1 | \