Skip to content

Commit

Permalink
Update storj-system-health.sh
Browse files Browse the repository at this point in the history
* checks, if discord.sh exists and is executable
* fixed: in case the script is called with an absolute path, discord.sh is still expected to be in the same folder, but will be correctly executed
  • Loading branch information
bjoerrrn authored Jan 12, 2022
1 parent a3e8a54 commit f0ce400
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion storj-system-health.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# v1.5.3
# v1.5.4
#
# 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 @@ -45,6 +45,9 @@ do
done
shift $((OPTIND-1))

# get current dir of this script
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

[[ "$VERBOSE" == "true" ]] && [[ $DEB -eq 1 ]] && echo -e " *** discord debug mode on"
[[ "$VERBOSE" == "true" ]] && [[ $DEB -eq 2 ]] && echo -e " *** mail debug mode on"

Expand All @@ -60,6 +63,13 @@ then
exit 2
fi

# check, if discord.sh script exists and is executable
if [ ! -x "$DIR/discord.sh" ]
then
echo "fatal: discord.sh does not exist or is not executable:$DIR/discord.sh"
exit 2
fi

# loads config data into variables
{ while IFS== read var values ; do IFS=, read -a $var <<< "$values"; done < "$config_file"; } 2>/dev/null

Expand Down Expand Up @@ -477,6 +487,7 @@ fi
# send discord ping
if [[ $tmp_fatal_errors -ne 0 ]] || [[ $tmp_io_errors -ne $tmp_rest_of_errors ]] || [[ $tmp_audits_failed -ne 0 ]] || [[ $get_repair_ratio_int -lt 95 ]] || [[ $put_repair_ratio_int -lt 95 ]] || [[ $get_ratio_int -lt 90 ]] || [[ $put_ratio_int -lt 90 ]] || $tmp_no_getput_1h || [[ $DEB -eq 1 ]]; then
if $DISCORDON; then
cd $DIR
{ ./discord.sh --webhook-url="$DISCORDURL" --username "storj stats" --text "$DLOG"; } 2>/dev/null
[[ "$VERBOSE" == "true" ]] && echo " *** discord summary push sent."
if [[ $satellite_scores != "" ]]; then
Expand Down Expand Up @@ -533,6 +544,7 @@ fi
### if relevant for you, enable the mail alert below.
else
if $DISCORDON; then
cd $DIR
{ ./discord.sh --webhook-url="$DISCORDURL" --username "storj stats" --text "**warning :** $NODE not running!"; } 2>/dev/null
fi
#swaks --from "$MAILFROM" --to "$MAILTO" --server "$MAILSERVER" --auth LOGIN --auth-user "$MAILUSER" --auth-password "$MAILPASS" --h-Subject "$NODE : NOT RUNNING" --body "warning: storage node is not running." --silent "1"
Expand Down

0 comments on commit f0ce400

Please sign in to comment.