From 2cfada7abe4d427620573793c336cdc89dee646d Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:37:37 -0600 Subject: [PATCH] Log fixes (#145) * Update piaware-log * first attempt * fixes * try fixes * fix grep statement? --- .../s6-rc.d/piaware-log/dependencies.d/01-piaware | 0 .../s6-overlay/s6-rc.d/piaware-log/dependencies.d/piaware | 0 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run | 2 -- rootfs/etc/s6-overlay/s6-rc.d/piaware-log/type | 1 - rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-log | 0 rootfs/etc/s6-overlay/scripts/piaware | 2 +- rootfs/etc/s6-overlay/scripts/piaware-log | 7 ------- rootfs/scripts/healthcheck.sh | 2 +- 8 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/01-piaware delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/piaware delete mode 100755 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/type delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-log delete mode 100755 rootfs/etc/s6-overlay/scripts/piaware-log diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/01-piaware b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/01-piaware deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/piaware b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/piaware deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run deleted file mode 100755 index f623f28..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec /etc/s6-overlay/scripts/piaware-log diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/type b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/type deleted file mode 100644 index 5883cff..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/type +++ /dev/null @@ -1 +0,0 @@ -longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-log b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-log deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/scripts/piaware b/rootfs/etc/s6-overlay/scripts/piaware index 88d006c..90efeb0 100755 --- a/rootfs/etc/s6-overlay/scripts/piaware +++ b/rootfs/etc/s6-overlay/scripts/piaware @@ -16,6 +16,6 @@ fi # shellcheck disable=SC2016 "${PIAWARE_BIN}" "${PIAWARE_CMD[@]}" \ - 2>&1 | stdbuf -o0 sed '/^$/d' | stdbuf -o0 awk '{print "[piaware] " strftime("%Y/%m/%d %H:%M:%S", systime()) " " $0}' + 2>&1 | stdbuf -o0 sed '/^$/d' | stdbuf -o0 awk '{print "[piaware] " strftime("%Y/%m/%d %H:%M:%S", systime()) " " $0}' | tee -a /var/log/piaware/current sleep 5 diff --git a/rootfs/etc/s6-overlay/scripts/piaware-log b/rootfs/etc/s6-overlay/scripts/piaware-log deleted file mode 100755 index 7f06899..0000000 --- a/rootfs/etc/s6-overlay/scripts/piaware-log +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/execlineb -#shellcheck shell=sh - -s6-envuidgid nobody -s6-applyuidgid -U - -s6-log -bp 1 n5 s400000 S10000000 T /var/log/piaware diff --git a/rootfs/scripts/healthcheck.sh b/rootfs/scripts/healthcheck.sh index 7a448d9..ccdc224 100755 --- a/rootfs/scripts/healthcheck.sh +++ b/rootfs/scripts/healthcheck.sh @@ -18,7 +18,7 @@ function check_logs_for_msgs_sent_to_fa () { # $1 = sending process (eg: dump1090, socat, dump978-fa) # $2 = number of output lines to consider (every line represents 5 minutes, so 12 would be an hour) # ------ - REGEX_FA_MSGS_SENT_PAST_5MIN="^(?'date'\d{4}-\d{1,2}-\d{1,2})\s+(?'time'\d{1,2}:\d{1,2}:[\d\.]+)\s+\[piaware\]\s+(?'date2'\d{4}\/\d{1,2}\/\d{1,2})\s+(?'time2'\d{1,2}:\d{1,2}:[\d\.]+)\s+\d+ msgs recv'd from $1 \(\K(?'msgslast5m'\d+) in last 5m\);\s+\d+ msgs sent to FlightAware\s*$" + REGEX_FA_MSGS_SENT_PAST_5MIN="^\[piaware\]\s+(?'date2'\d{4}\/\d{1,2}\/\d{1,2})\s+(?'time2'\d{1,2}:\d{1,2}:[\d\.]+)\s+\d+ msgs recv'd from $1 \(\K(?'msgslast5m'\d+) in last 5m\);\s+\d+ msgs sent to FlightAware\s*$" NUM_MSGS_RECEIVED=$(tail -$(($2 * 10)) /var/log/piaware/current | grep -oP "$REGEX_FA_MSGS_SENT_PAST_5MIN" | tail "-$2" | tr -s " " | cut -d " " -f 1) TOTAL_MSGS_RECEIVED=0 for NUM_MSGS in $NUM_MSGS_RECEIVED; do