Skip to content

Commit 590faa3

Browse files
author
Oliver Cervera
authored
Send summary to Healthchecks
- Added summary to Healthchecks output. We could send more stuff if needed: Healthchecks supports up to 10 KB per query, but I think it's better to keep it short. - Adjust quoting in Healthchecks query
1 parent 49087c0 commit 590faa3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

snapraid-aio-script.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
######################
99
# CONFIG VARIABLES #
1010
######################
11-
SNAPSCRIPTVERSION="2.9.DEV6"
11+
SNAPSCRIPTVERSION="2.9.DEV7"
1212

1313
# Read SnapRAID version
1414
SNAPRAIDVERSION="$(snapraid -V | sed -e 's/snapraid v\(.*\)by.*/\1/')"
@@ -60,7 +60,7 @@ function main(){
6060
apt-get install -qq -o=Dpkg::Use-Pty=0 curl;
6161
fi
6262
echo "Healthchecks.io integration is enabled."
63-
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID/start"
63+
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/start
6464
fi
6565

6666
# Check if script configuration file has been found
@@ -648,22 +648,26 @@ function prepare_mail() {
648648
elif [ -z "${JOBS_DONE##*"SCRUB"*}" ] && ! grep -qw "$SCRUB_MARKER" "$TMP_OUTPUT"; then
649649
# Scrub ran but did not complete successfully so lets warn the user
650650
SUBJECT="[WARNING] SCRUB job ran but did not complete successfully $EMAIL_SUBJECT_PREFIX"
651+
HC_OUTPUT="$SUBJECT
652+
SUMMARY: Equal [$EQ_COUNT] - Added [$ADD_COUNT] - Deleted [$DEL_COUNT] - Moved [$MOVE_COUNT] - Copied [$COPY_COUNT] - Updated [$UPDATE_COUNT]"
651653
healthchecks_warning
652654
else
653655
SUBJECT="[COMPLETED] $JOBS_DONE Jobs $EMAIL_SUBJECT_PREFIX"
656+
HC_OUTPUT="$SUBJECT
657+
SUMMARY: Equal [$EQ_COUNT] - Added [$ADD_COUNT] - Deleted [$DEL_COUNT] - Moved [$MOVE_COUNT] - Copied [$COPY_COUNT] - Updated [$UPDATE_COUNT]"
654658
healthchecks_success
655659
fi
656660
}
657661

658662
function healthchecks_success(){
659663
if [ "$HEALTHCHECKS" -eq 1 ]; then
660-
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/0 --data-raw "$SUBJECT"
664+
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/0 --data-raw "$HC_OUTPUT"
661665
fi
662666
}
663667

664668
function healthchecks_warning(){
665669
if [ "$HEALTHCHECKS" -eq 1 ]; then
666-
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/fail --data-raw "$SUBJECT"
670+
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/fail --data-raw "HC_OUTPUT"
667671
fi
668672
}
669673

0 commit comments

Comments
 (0)