Watchdog error handling

pull/3/head
Dominik Dzienia 2 years ago
parent 261d23c50c
commit 2c60195d4f

@ -1029,13 +1029,13 @@ admin_panel_promo() {
} }
get_watchdog_age_string() { get_watchdog_age_string() {
local curr_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
local last_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ") local last_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
local curr_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
if [[ -f $WATCHDOG_TIME_FILE ]]; then if [[ -f $WATCHDOG_TIME_FILE ]]; then
last_time=$(cat $WATCHDOG_TIME_FILE) last_time=$(cat $WATCHDOG_TIME_FILE)
local status_ago=$(dateutils.ddiff "$last_time" "$curr_time" -f '%Mmin. %Ssek.') local status_ago=$(dateutils.ddiff "$last_time" "$curr_time" -f '%Mmin. %Ssek.')
echo "$last_time ($status_ago temu)" echo "$last_time ($status_ago temu)"
else else
echo "jescze nie uruchomiony" echo "jescze nie uruchomiony"
fi fi
@ -1088,19 +1088,26 @@ get_watchdog_status_code_live() {
if [ "$COMBINED_STATUS" = "running running" ]; then if [ "$COMBINED_STATUS" = "running running" ]; then
local domain=$(get_td_domain) local domain=$(get_td_domain)
local html=$(curl -Lks "$domain") local domainLen=${#domain}
if ((domainLen > 15)); then
if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then local html=$(curl -Lks "$domain")
status="ok"
fi
if [[ "$html" =~ 'MongoDB connection failed' ]]; then if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then
status="crashed" status="ok"
fi fi
regex3='MIKR.US - coś poszło nie tak' if [[ "$html" =~ 'MongoDB connection failed' ]]; then
if [[ "$html" =~ $regex3 ]]; then status="crashed"
status="restarting" fi
regex3='MIKR.US - coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then
status="restarting"
fi
else
status="detection_failed"
fi fi
else else
@ -1166,7 +1173,7 @@ show_watchdog_logs() {
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "Log ostatniego przebiegu watchdoga:" echo "Log ostatniego przebiegu watchdoga:"
cat "$WATCHDOG_CRON_LOG" cat "$WATCHDOG_CRON_LOG"
} >"$tmpfile" } >"$tmpfile"
whiptail --title "Logi Watchdoga" --scrolltext --textbox "$tmpfile" $rws $col whiptail --title "Logi Watchdoga" --scrolltext --textbox "$tmpfile" $rws $col
@ -1571,28 +1578,35 @@ watchdog_check() {
if [ "$COMBINED_STATUS" = "running running" ]; then if [ "$COMBINED_STATUS" = "running running" ]; then
echo "Will check page contents" echo "Will check page contents"
local domain=$(get_td_domain) local domain=$(get_td_domain)
local html=$(curl -Lks "$domain")
WATCHDOG_STATUS="detection_failed" local domainLen=${#domain}
if ((domainLen > 15)); then
local html=$(curl -Lks "$domain")
if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then WATCHDOG_STATUS="detection_failed"
echo "Nightscout is running"
WATCHDOG_STATUS="ok"
fi
if [[ "$html" =~ 'MongoDB connection failed' ]]; then if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then
echo "Nightscout is crashed, restarting..." echo "Nightscout is running"
WATCHDOG_STATUS="restart" WATCHDOG_STATUS="ok"
if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then
docker restart 'ns-server'
echo "...done"
fi fi
fi
regex3='MIKR.US - coś poszło nie tak' if [[ "$html" =~ 'MongoDB connection failed' ]]; then
if [[ "$html" =~ $regex3 ]]; then echo "Nightscout is crashed, restarting..."
echo "Nightscout is still restarting..." WATCHDOG_STATUS="restart"
WATCHDOG_STATUS="restarting" if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then
docker restart 'ns-server'
echo "...done"
fi
fi
regex3='MIKR.US - coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then
echo "Nightscout is still restarting..."
WATCHDOG_STATUS="restarting"
fi
else
WATCHDOG_STATUS="detection_failed"
fi fi
else else

@ -1013,13 +1013,13 @@ admin_panel_promo() {
} }
get_watchdog_age_string() { get_watchdog_age_string() {
local curr_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
local last_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ") local last_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
local curr_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
if [[ -f $WATCHDOG_TIME_FILE ]]; then if [[ -f $WATCHDOG_TIME_FILE ]]; then
last_time=$(cat $WATCHDOG_TIME_FILE) last_time=$(cat $WATCHDOG_TIME_FILE)
local status_ago=$(dateutils.ddiff "$last_time" "$curr_time" -f '%Mmin. %Ssek.') local status_ago=$(dateutils.ddiff "$last_time" "$curr_time" -f '%Mmin. %Ssek.')
echo "$last_time ($status_ago temu)" echo "$last_time ($status_ago temu)"
else else
echo "jescze nie uruchomiony" echo "jescze nie uruchomiony"
fi fi
@ -1072,19 +1072,26 @@ get_watchdog_status_code_live() {
if [ "$COMBINED_STATUS" = "running running" ]; then if [ "$COMBINED_STATUS" = "running running" ]; then
local domain=$(get_td_domain) local domain=$(get_td_domain)
local html=$(curl -Lks "$domain") local domainLen=${#domain}
if ((domainLen > 15)); then
if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then local html=$(curl -Lks "$domain")
status="ok"
fi
if [[ "$html" =~ 'MongoDB connection failed' ]]; then if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then
status="crashed" status="ok"
fi fi
regex3='MIKR.US - coś poszło nie tak' if [[ "$html" =~ 'MongoDB connection failed' ]]; then
if [[ "$html" =~ $regex3 ]]; then status="crashed"
status="restarting" fi
regex3='MIKR.US - coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then
status="restarting"
fi
else
status="detection_failed"
fi fi
else else
@ -1150,7 +1157,7 @@ show_watchdog_logs() {
echo "-------------------------------------------------------" echo "-------------------------------------------------------"
echo "Log ostatniego przebiegu watchdoga:" echo "Log ostatniego przebiegu watchdoga:"
cat "$WATCHDOG_CRON_LOG" cat "$WATCHDOG_CRON_LOG"
} >"$tmpfile" } >"$tmpfile"
whiptail --title "Logi Watchdoga" --scrolltext --textbox "$tmpfile" $rws $col whiptail --title "Logi Watchdoga" --scrolltext --textbox "$tmpfile" $rws $col
@ -1555,28 +1562,35 @@ watchdog_check() {
if [ "$COMBINED_STATUS" = "running running" ]; then if [ "$COMBINED_STATUS" = "running running" ]; then
echo "Will check page contents" echo "Will check page contents"
local domain=$(get_td_domain) local domain=$(get_td_domain)
local html=$(curl -Lks "$domain")
WATCHDOG_STATUS="detection_failed" local domainLen=${#domain}
if ((domainLen > 15)); then
local html=$(curl -Lks "$domain")
if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then WATCHDOG_STATUS="detection_failed"
echo "Nightscout is running"
WATCHDOG_STATUS="ok"
fi
if [[ "$html" =~ 'MongoDB connection failed' ]]; then if [[ "$html" =~ github.com/nightscout/cgm-remote-monitor ]]; then
echo "Nightscout is crashed, restarting..." echo "Nightscout is running"
WATCHDOG_STATUS="restart" WATCHDOG_STATUS="ok"
if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then
docker restart 'ns-server'
echo "...done"
fi fi
fi
regex3='MIKR.US - coś poszło nie tak' if [[ "$html" =~ 'MongoDB connection failed' ]]; then
if [[ "$html" =~ $regex3 ]]; then echo "Nightscout is crashed, restarting..."
echo "Nightscout is still restarting..." WATCHDOG_STATUS="restart"
WATCHDOG_STATUS="restarting" if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then
docker restart 'ns-server'
echo "...done"
fi
fi
regex3='MIKR.US - coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then
echo "Nightscout is still restarting..."
WATCHDOG_STATUS="restarting"
fi
else
WATCHDOG_STATUS="detection_failed"
fi fi
else else

@ -1 +1 @@
2024-01-07T13:33:40.615Z 2024-01-07T14:13:41.909Z
Loading…
Cancel
Save