From f1d95499e3df2860279f826e4e36c00d80e79a38 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 29 Aug 2023 10:36:46 -0600 Subject: [PATCH 1/5] Update piaware-log --- rootfs/etc/s6-overlay/scripts/piaware-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/s6-overlay/scripts/piaware-log b/rootfs/etc/s6-overlay/scripts/piaware-log index 7f06899..4145acc 100755 --- a/rootfs/etc/s6-overlay/scripts/piaware-log +++ b/rootfs/etc/s6-overlay/scripts/piaware-log @@ -1,4 +1,4 @@ -#!/usr/bin/execlineb +#!/command/execlineb #shellcheck shell=sh s6-envuidgid nobody From 0889ce9e44f2792256ffab72e4243abe7b5f137b Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 29 Aug 2023 10:57:54 -0600 Subject: [PATCH 2/5] first attempt --- .../piaware => 02-piaware-log-prepare/dependencies.d/base} | 0 rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up | 3 +++ rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for | 1 + rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name | 1 + rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run | 2 +- .../dependencies.d/02-piaware-log-prepare} | 0 rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for | 1 + rootfs/etc/s6-overlay/s6-rc.d/piaware/run | 1 + rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline | 0 9 files changed, 8 insertions(+), 1 deletion(-) rename rootfs/etc/s6-overlay/s6-rc.d/{piaware-log/dependencies.d/piaware => 02-piaware-log-prepare/dependencies.d/base} (100%) create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name rename rootfs/etc/s6-overlay/s6-rc.d/{user/contents.d/piaware-log => piaware/dependencies.d/02-piaware-log-prepare} (100%) create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/piaware b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/dependencies.d/base similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/piaware-log/dependencies.d/piaware rename to rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/dependencies.d/base diff --git a/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up new file mode 100755 index 0000000..1cee1e9 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up @@ -0,0 +1,3 @@ +if { mkdir -p /var/log/piaware } +if { chown nobody:nogroup /var/log/piaware } +chmod 02755 /var/log/piaware \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for new file mode 100644 index 0000000..29efc2d --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for @@ -0,0 +1 @@ +piaware \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name new file mode 100644 index 0000000..b7d9e2c --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name @@ -0,0 +1 @@ +piaware-pipeline \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run index f623f28..9f1da17 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run @@ -1,2 +1,2 @@ #!/bin/sh -exec /etc/s6-overlay/scripts/piaware-log +exec logutil-service /var/log/piaware \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-log b/rootfs/etc/s6-overlay/s6-rc.d/piaware/dependencies.d/02-piaware-log-prepare similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-log rename to rootfs/etc/s6-overlay/s6-rc.d/piaware/dependencies.d/02-piaware-log-prepare diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for b/rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for new file mode 100644 index 0000000..c4fc18e --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for @@ -0,0 +1 @@ +piaware-log \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware/run b/rootfs/etc/s6-overlay/s6-rc.d/piaware/run index 261037b..1ce6dab 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/piaware/run @@ -1,2 +1,3 @@ #!/bin/sh +exec 2>&1 exec /etc/s6-overlay/scripts/piaware diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline new file mode 100644 index 0000000..e69de29 From b461848f07dbcf33d9a965fbc5a8974a3c703d2c Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:03:08 -0600 Subject: [PATCH 3/5] fixes --- rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type | 1 + rootfs/etc/s6-overlay/scripts/piaware-log | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type delete mode 100755 rootfs/etc/s6-overlay/scripts/piaware-log diff --git a/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/scripts/piaware-log b/rootfs/etc/s6-overlay/scripts/piaware-log deleted file mode 100755 index 4145acc..0000000 --- a/rootfs/etc/s6-overlay/scripts/piaware-log +++ /dev/null @@ -1,7 +0,0 @@ -#!/command/execlineb -#shellcheck shell=sh - -s6-envuidgid nobody -s6-applyuidgid -U - -s6-log -bp 1 n5 s400000 S10000000 T /var/log/piaware From e848329eb0e7f6d82b715ffba040a19e8a931330 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:08:34 -0600 Subject: [PATCH 4/5] try fixes --- .../s6-rc.d/02-piaware-log-prepare/dependencies.d/base | 0 rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type | 1 - rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up | 3 --- rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for | 1 - .../s6-overlay/s6-rc.d/piaware-log/dependencies.d/01-piaware | 0 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name | 1 - rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run | 2 -- rootfs/etc/s6-overlay/s6-rc.d/piaware-log/type | 1 - .../s6-rc.d/piaware/dependencies.d/02-piaware-log-prepare | 0 rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for | 1 - rootfs/etc/s6-overlay/s6-rc.d/piaware/run | 1 - rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline | 0 rootfs/etc/s6-overlay/scripts/piaware | 2 +- 13 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/dependencies.d/base delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type delete mode 100755 rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for 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/pipeline-name 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/piaware/dependencies.d/02-piaware-log-prepare delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline diff --git a/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/dependencies.d/base b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/dependencies.d/base deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type deleted file mode 100644 index 3d92b15..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/type +++ /dev/null @@ -1 +0,0 @@ -oneshot \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up b/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up deleted file mode 100755 index 1cee1e9..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/02-piaware-log-prepare/up +++ /dev/null @@ -1,3 +0,0 @@ -if { mkdir -p /var/log/piaware } -if { chown nobody:nogroup /var/log/piaware } -chmod 02755 /var/log/piaware \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for deleted file mode 100644 index 29efc2d..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/consumer-for +++ /dev/null @@ -1 +0,0 @@ -piaware \ No newline at end of file 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/pipeline-name b/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name deleted file mode 100644 index b7d9e2c..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/pipeline-name +++ /dev/null @@ -1 +0,0 @@ -piaware-pipeline \ No newline at end of file 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 9f1da17..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware-log/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec logutil-service /var/log/piaware \ No newline at end of file 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/piaware/dependencies.d/02-piaware-log-prepare b/rootfs/etc/s6-overlay/s6-rc.d/piaware/dependencies.d/02-piaware-log-prepare deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for b/rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for deleted file mode 100644 index c4fc18e..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware/producer-for +++ /dev/null @@ -1 +0,0 @@ -piaware-log \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/piaware/run b/rootfs/etc/s6-overlay/s6-rc.d/piaware/run index 1ce6dab..261037b 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/piaware/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/piaware/run @@ -1,3 +1,2 @@ #!/bin/sh -exec 2>&1 exec /etc/s6-overlay/scripts/piaware diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/piaware-pipeline 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 From e50b622613cf3cedb8c402ac54783bcd7d6dcaa0 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:26:31 -0600 Subject: [PATCH 5/5] fix grep statement? --- rootfs/scripts/healthcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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