Service Status Webhooks

Nagios → Alert24: Automatically Update Service Status

Automatically update Alert24 service status when Nagios detects a state change. Covers webhook receiver setup, event handler script, and status mapping.

When Nagios detects that a service is down or degraded, you can automatically push that status into Alert24 so your Alert24 status page reflects the real state — without manually updating it. This uses Alert24's incoming webhook receiver.

Step 1: Create a webhook receiver in Alert24

  1. Go to Settings → Webhook Receivers → Add receiver
  2. Give it a name (e.g., "Nagios status updates")
  3. Link it to the Service you want to update (e.g., "API Gateway")
  4. Set Status field path to current_state (the field in the webhook payload that carries the status)
  5. Set Status mapping:
    operational → OK, UP
    degraded → WARNING
    down → CRITICAL, DOWN, UNREACHABLE
    
  6. Enable Auto-create incidents if you want Alert24 to open an incident automatically
  7. Save — Alert24 gives you an incoming webhook URL:
    https://app.alert24.net/api/webhooks/incoming/YOUR_TOKEN
    

Step 2: Create the event handler script

Save to /usr/local/nagios/libexec/alert24_status.sh:

#!/bin/bash
# Update Alert24 service status from Nagios state changes

STATE="$1"          # OK / WARNING / CRITICAL / UNKNOWN / UP / DOWN
STATE_TYPE="$2"     # SOFT / HARD
SERVICE_DESC="$3"
HOST="$4"
WEBHOOK_URL="https://app.alert24.net/api/webhooks/incoming/YOUR_TOKEN"

# Only update on HARD state changes
if [ "$STATE_TYPE" != "HARD" ]; then
  exit 0
fi

curl -s -X POST "$WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -d "{
    \"current_state\": \"$STATE\",
    \"host\": \"$HOST\",
    \"service\": \"$SERVICE_DESC\",
    \"source\": \"nagios\"
  }"

Make it executable: chmod +x /usr/local/nagios/libexec/alert24_status.sh

Step 3: Wire up the event handler

In commands.cfg:

define command {
  command_name  alert24_status
  command_line  /usr/local/nagios/libexec/alert24_status.sh \
                  "$SERVICESTATE$" "$SERVICESTATETYPE$" \
                  "$SERVICEDESC$" "$HOSTNAME$"
}

In your service definition:

define service {
  use                   generic-service
  host_name             web-prod-01
  service_description   HTTP Check
  check_command         check_http
  event_handler         alert24_status
  event_handler_enabled 1
}

Tips

  • HARD vs SOFT: Nagios retries checks several times before declaring a HARD state. Only update Alert24 on HARD changes to avoid flickering the status page during retries.
  • Multiple services: Create one Alert24 webhook receiver per service and use separate event handlers for each, or use a single receiver and a smarter script that maps Nagios hostnames to Alert24 service IDs.
  • Recovery: When Nagios sends OK or UP, the status mapping sends operational to Alert24 — your status page automatically shows green.