feat: Update webhook notification system to include enhanced message context and tags

This commit is contained in:
Peter Wood
2025-05-26 09:34:19 -04:00
parent 1d01ca8c61
commit b994508774

View File

@@ -36,7 +36,7 @@ INTEGRITY_CHECK_ONLY=false
INTERACTIVE_MODE=true INTERACTIVE_MODE=true
PARALLEL_VERIFICATION=true PARALLEL_VERIFICATION=true
PERFORMANCE_MONITORING=true PERFORMANCE_MONITORING=true
WEBHOOK_URL="" WEBHOOK_URL="https://notify.peterwood.rocks/lab"
EMAIL_RECIPIENT="" EMAIL_RECIPIENT=""
# Parse command line arguments # Parse command line arguments
@@ -198,23 +198,17 @@ send_notification() {
# Webhook notification # Webhook notification
if [ -n "$WEBHOOK_URL" ]; then if [ -n "$WEBHOOK_URL" ]; then
local payload=$(jq -n \ local tags="backup,plex,${hostname}"
--arg title "$title" \ [ "$status" == "error" ] && tags="${tags},errors"
--arg message "$message" \ [ "$status" == "warning" ] && tags="${tags},warnings"
--arg status "$status" \
--arg hostname "$hostname" \
--arg timestamp "$(date -Iseconds)" \
'{
title: $title,
message: $message,
status: $status,
hostname: $hostname,
timestamp: $timestamp
}')
curl -s -X POST "$WEBHOOK_URL" \ # Enhanced message with additional context
-H "Content-Type: application/json" \ local enhanced_message="$message\n\nHost: $hostname\nTimestamp: $(date '+%Y-%m-%d %H:%M:%S')"
-d "$payload" > /dev/null 2>&1 || true
curl -s \
-H "tags:${tags}" \
-d "$enhanced_message" \
"$WEBHOOK_URL" 2>/dev/null || log_warning "Failed to send webhook notification"
fi fi
# Email notification (if sendmail is available) # Email notification (if sendmail is available)