Get real-time notifications for important events via Discord or Slack webhooks.
WPFleet's notification system keeps you informed about:
- Backup completion and failures
- Service health issues
- Disk space warnings
- SSL certificate expiration
- Git deployment status
- Disk quota violations
- Discord: Rich embeds with color coding
- Slack: Formatted messages with attachments
- Both platforms can be enabled simultaneously
-
Create a webhook in your Discord server:
- Go to Server Settings → Integrations → Webhooks
- Click "New Webhook"
- Name it (e.g., "WPFleet Notifications")
- Select the channel for notifications
- Copy the webhook URL
-
Add to WPFleet configuration in
.env:
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN- Test the webhook:
./scripts/notify.sh test-
Create an Incoming Webhook:
- Go to your Slack workspace settings
- Navigate to Apps → Custom Integrations → Incoming Webhooks
- Click "Add to Slack"
- Choose the channel for notifications
- Copy the webhook URL
-
Add to WPFleet configuration in
.env:
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL- Test the webhook:
./scripts/notify.sh testYou can receive notifications on both Discord and Slack:
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...Sent for successful operations:
- Backup completion
- Site deployment success
- Health check passed
- Git deployment success
Sent for potential issues:
- Disk space > 80%
- SSL certificate expiring soon (< 30 days)
- Disk quota > 80%
- Service degraded performance
Sent for failures and critical issues:
- Backup failure
- Service down
- Disk space > 90%
- Database connection failure
- Git deployment failure
- Disk quota exceeded
Send custom notifications from scripts or command line:
./scripts/notify.sh success "Deployment Complete" "Successfully deployed to production"./scripts/notify.sh warning "High Memory Usage" "Memory usage at 85%"./scripts/notify.sh error "Backup Failed" "Failed to backup example.com"./scripts/notify.sh info "Maintenance" "Starting system maintenance"Notifications are automatically sent for these events:
# Configured in backup script
✓ Backup completed successfully
✗ Backup failed
⚠ Backup took longer than expected# Configured in health-check script
✗ MariaDB not responding
✗ Valkey not responding
✗ FrankenPHP not responding
⚠ High disk usage (>80%)
✗ Critical disk usage (>90%)# Configured in git-deploy script
✓ Theme deployed successfully
✓ Plugin deployed successfully
✗ Git clone failed
✗ Deployment failed# Configured in quota-manager script
⚠ Site approaching quota limit (>80%)
✗ Site exceeded quota limitExample of adding notifications to a custom script:
#!/bin/bash
# Source the notification library
source "$(dirname "$0")/lib/notify.sh"
# Your script logic
if [ $? -eq 0 ]; then
send_notification "success" "Task Completed" "Your task finished successfully"
else
send_notification "error" "Task Failed" "Your task encountered an error"
fiThe notify.sh script accepts:
./scripts/notify.sh <level> <title> <message> [url]Parameters:
level: success, warning, error, infotitle: Short title (shown prominently)message: Detailed messageurl: Optional URL to include
Example with URL:
./scripts/notify.sh success "Site Live" "example.com is now live" "https://example.com"Create dedicated channels for different notification types:
#wpfleet-critical- Errors only#wpfleet-alerts- Warnings and errors#wpfleet-all- All notifications
Use separate webhooks for each channel.
Avoid notification spam:
- Combine related events
- Use summary notifications for bulk operations
- Implement cooldown periods for recurring warnings
Include useful details:
- Site affected
- Error messages
- How to fix
- Links to logs or dashboards
Test notifications after changes:
./scripts/notify.sh test-
Verify webhook URLs:
echo $DISCORD_WEBHOOK_URL echo $SLACK_WEBHOOK_URL
-
Test webhooks manually:
./scripts/notify.sh test -
Check webhook validity:
- Discord: Go to Server Settings → Integrations → Webhooks
- Slack: Check Incoming Webhooks in your workspace settings
-
Check script permissions:
ls -l scripts/notify.sh chmod +x scripts/notify.sh
-
Verify curl is installed:
curl --version
-
Check JSON formatting in notify.sh script
-
Test with simple message:
./scripts/notify.sh info "Test" "Simple message"
If webhooks are deleted or recreated:
- Generate new webhook URL in Discord/Slack
- Update
.envfile - Test with:
./scripts/notify.sh test
Discord and Slack have rate limits. If you hit them:
- Reduce notification frequency
- Batch notifications
- Add delays between notifications:
./scripts/notify.sh success "Title 1" "Message 1" sleep 2 ./scripts/notify.sh success "Title 2" "Message 2"
# In .env CUSTOM_CRON_JOBS
0 2 * * * cd /wpfleet && ./scripts/backup.sh all && ./scripts/notify.sh success "Backups" "All sites backed up"# In .git/hooks/post-commit
#!/bin/bash
./scripts/notify.sh info "Git Commit" "New commit: $(git log -1 --pretty=%B)"# Custom monitoring script
#!/bin/bash
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}')
if (( $(echo "$CPU_USAGE > 80" | bc -l) )); then
./scripts/notify.sh warning "High CPU" "CPU usage at $CPU_USAGE%"
fi# Deployment script
#!/bin/bash
./scripts/git-deploy.sh theme example.com https://github.com/user/theme.git
if [ $? -eq 0 ]; then
./scripts/notify.sh success "Deployment" "Theme deployed to example.com"
else
./scripts/notify.sh error "Deployment Failed" "Theme deployment failed"
fiCreate a wrapper for your specific needs:
#!/bin/bash
# custom-notify.sh
SITE=$1
ACTION=$2
STATUS=$3
if [ "$STATUS" = "success" ]; then
./scripts/notify.sh success \
"[$SITE] $ACTION" \
"Successfully completed $ACTION on $SITE" \
"https://$SITE"
else
./scripts/notify.sh error \
"[$SITE] $ACTION Failed" \
"Failed to complete $ACTION on $SITE" \
"https://$SITE"
fiUsage:
./custom-notify.sh example.com "Backup" "success"Use different webhooks for staging vs production:
# Production .env
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/.../production
# Staging .env
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/.../stagingCreate notification levels:
# In your scripts
NOTIFICATION_LEVEL=${NOTIFICATION_LEVEL:-"warning"}
send_filtered_notification() {
local level=$1
local title=$2
local message=$3
case $level in
error)
./scripts/notify.sh error "$title" "$message"
;;
warning)
if [[ "$NOTIFICATION_LEVEL" =~ ^(warning|info)$ ]]; then
./scripts/notify.sh warning "$title" "$message"
fi
;;
info)
if [ "$NOTIFICATION_LEVEL" = "info" ]; then
./scripts/notify.sh info "$title" "$message"
fi
;;
esac
}- Protect webhook URLs: Keep them secret in
.env - Don't commit webhooks: Ensure
.envis in.gitignore - Regenerate if exposed: Generate new webhooks if accidentally exposed
- Limit permissions: Use read-only channels when possible
- Sanitize messages: Avoid including sensitive data in notifications