-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove the HC checking of messages received * create message monitor service to log any UAT traffic issues * updates * add needed s6 stuff * fix typo/bug * bug fix * add restart_when_stale and other updates * make things a bit more verbose --------- Co-authored-by: kx1t <[email protected]>
- Loading branch information
1 parent
a04774f
commit 223d255
Showing
13 changed files
with
71 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
exec /etc/s6-overlay/scripts/message-monitor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
longrun |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/command/with-contenv bash | ||
#shellcheck shell=bash disable=SC1091 | ||
|
||
source /scripts/common | ||
mkdir -p /run/stats | ||
s6wrap=(s6wrap --quiet --prepend="$(basename "$0")" --timestamps --args) | ||
|
||
while : | ||
do | ||
# Make sure we're receiving messages from the SDR | ||
# get the number of messages received since process start: | ||
|
||
if [[ -f /run/skyaware978/aircraft.json ]]; then | ||
read -r new_msg_count <<< "$(jq .messages /run/skyaware978/aircraft.json 2>/dev/null)" | ||
else | ||
new_msg_count="STARTING" | ||
fi | ||
# get the number of messages previously read, or 0 if there's no history: | ||
if [[ -f /run/stats/msgs_since_last_monitor_run ]]; then | ||
read -r old_msg_count < /run/stats/msgs_since_last_monitor_run | ||
secs_since_last_check="$(( $(date +%s) - $(stat -c '%Y' /run/stats/msgs_since_last_monitor_run) ))" | ||
else | ||
old_msg_count=0 | ||
secs_since_last_check="$(( $(date +%s) - $(stat -c '%Y' /run/service/skyaware978) ))" # use skyaware978 modify time as the creation time of the container | ||
fi | ||
|
||
# if new_msg_count < old_msg_count, dump978 must have restarted since the previous run of this script | ||
# in that case, assume that old_msg_count=0 | ||
if (( new_msg_count < old_msg_count )); then | ||
old_msg_count=0 | ||
fi | ||
|
||
if [[ "$new_msg_count" == "STARTING" ]]; then | ||
"${s6wrap[@]}" echo "[STARTING] Receiver starting: No messages have been received as the container is still starting" | ||
new_msg_count=0 | ||
elif (( new_msg_count == old_msg_count )); then | ||
"${s6wrap[@]}" echo "[WARNING] Receiver appears stale: No messages received since last run of the Messages Monitor ($secs_since_last_check secs ago)" | ||
if chk_enabled "$DUMP978_MSG_MONITOR_RESTART_WHEN_STALE"; then | ||
"${s6wrap[@]}" echo "[WARNING] Restarting the dump978 service..." | ||
s6-svc -r /run/service/dump978 2>/dev/null || true | ||
fi | ||
elif (( new_msg_count > old_msg_count )); then | ||
"${s6wrap[@]}" echo "[INFO] Receiver is OK: $(( new_msg_count - old_msg_count )) messages received since last run of the Messages Monitor ($secs_since_last_check secs ago)" | ||
else | ||
"${s6wrap[@]}" echo "[ERROR] This situation cannot occur, please notify the software maintainers. new_msg_count=$new_msg_count; old_msg_count=$old_msg_count" | ||
fi | ||
echo "$new_msg_count" > /run/stats/msgs_since_last_monitor_run | ||
|
||
sleep "${DUMP978_MSG_MONITOR_INTERVAL:-30m}" & wait $! | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters