Skip to content

Commit

Permalink
Update storj-system-health.sh
Browse files Browse the repository at this point in the history
* fixed handling on payout estimations for new nodes added to the settings
* fixed a minor logical error, which caused a command line warning in verbose mode
  • Loading branch information
bjoerrrn authored Sep 19, 2022
1 parent 3d80c9a commit 56f2346
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions storj-system-health.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# v1.9.4
# v1.9.5
#
# storj-system-health.sh - storagenode health checks and notifications to discord / by email
# by dusselmann, https://github.com/dusselmann/storj-system-health.sh
Expand Down Expand Up @@ -868,7 +868,7 @@ fi # // end of if clause for skipping docker logs analysis
if [[ $tmp_payDateDay -ne $tmp_todayDay ]]; then
tmp_payValid=true;
[[ "$DEBUG" == "true" ]] && echo "... settings : tmp_payValid=$tmp_payValid"
# if payDate timestamp between 23:45:00 and 23:59:59 (hh:mm:ss); then payComplete = true; else payComplete = false;
# if payDate timestamp between 23:50:00 and 23:59:59 (hh:mm:ss); then payComplete = true; else payComplete = false;
[[ $tmp_payDateHour -eq 23 ]] && [[ $tmp_payDateMinutes -ge 50 ]] && [[ $tmp_payDateMinutes -le 59 ]] && tmp_payComplete=true;
[[ "$DEBUG" == "true" ]] && echo "... settings : tmp_payComplete=$tmp_payComplete"
fi
Expand All @@ -891,16 +891,22 @@ fi # // end of if clause for skipping docker logs analysis
[[ "$DEBUG" == "true" ]] && echo "... settings : tmp_payDiff=$tmp_payDiff"

# pay data and last timestamp valid and current timestamp at the end of the current day, then store new values
if [[ "$tmp_payValid" == "true" && "$tmp_payComplete" == "true" ]]; then
if [[ $tmp_todayHour -eq 23 && $tmp_todayMinutes -ge 50 && $tmp_todayMinutes -le 59 ]]; then
if [[ $tmp_todayHour -eq 23 && $tmp_todayMinutes -ge 50 && $tmp_todayMinutes -le 59 ]]; then
if [[ "$tmp_payValid" == "true" && "$tmp_payComplete" == "true" ]]; then
# set payValue = estimatedPayoutTotal --> persistent storage !!
updateSettings "${NODE}_payValue" "$tmp_estimatedPayoutTotal";
# set payDate = timestamp --> persistent storage !!
updateSettings "${NODE}_payTimestamp" "$tmp_timestamp";
elif [[ "$tmp_payValid" == "true" && "$tmp_payComplete" == "false" && settings["${NODE}_payValue"] == "0" ]]; then
# in case of new nodes added to the settings with initial setup during the day,
# the timestamp update will fix the 'complete' checks and calculations on the first evening.
# note: this is not a full solution, but values will be correct from the second day onwards.
updateSettings "${NODE}_payTimestamp" "$tmp_timestamp";
fi # // end of store new values if clause

fi # // end of payout estimation if clause
fi # // end of $settings_file readable if clause



# =============================================================================
Expand Down Expand Up @@ -1008,7 +1014,7 @@ if [[ "$DISCORDON" == "true" ]]; then
$tmp_audits_failed -ne 0 -o $temp_severe_errors -ne 0 -o \
\( $get_repair_started -ne 0 -a $get_repair_ratio_int -lt 95 \) -o \
$tmp_reps_failed -ne 0 -o $get_ratio_int -lt 90 -o $put_ratio_int -lt 90 -o \
"$tmp_no_getput_1h" == "true" -o "$SENDPUSH" == "true" -o "$tmp_auditTimeLagsFilled" == "true"]; then
"$tmp_no_getput_1h" == "true" -o "$SENDPUSH" == "true" -o "$tmp_auditTimeLagsFilled" == "true" ]; then

{ ./discord.sh --webhook-url="$DISCORDURL" --username "health check" --text "$DLOG"; } 2>/dev/null
[[ "$VERBOSE" == "true" ]] && echo " *** discord summary push sent: $DLOG"
Expand Down

0 comments on commit 56f2346

Please sign in to comment.