logo

CALLGOOSE

Monit

Overview

This document provides a complete, beginner-friendly guide to integrating Monit with Callgoose SQIBS using script-based notifications.

Monit monitors system processes, services, filesystems, and resources. When it detects a failure or recovery, Monit can execute a script using the exec action. In this integration, that script sends a JSON payload to Callgoose SQIBS, enabling automatic incident creation and resolution.

This integration enables:

  • Real-time incident creation for Monit alerts.
  • Automatic incident resolution when services recover.
  • Complete mapping control using Callgoose API Filters.
  • Lightweight host-based integration without additional dependencies.

Prerequisites

Before starting, ensure you have:

  • A running machine where Monit can be installed.
  • Permission to edit Monit configuration (/etc/monitrc, /etc/monit/conf.d/).
  • A Callgoose SQIBS API endpoint with a token.
  • curl installed on the host.
  • Basic understanding of Monit’s check, if, and exec rules.

1. Install Monit

1.1 Install on Debian / Ubuntu

sudo apt update
sudo apt install monit
sudo systemctl enable monit
sudo systemctl start monit

1.2 Install on RHEL / CentOS / AlmaLinux / Rocky

sudo yum install epel-release
sudo yum install monit
sudo systemctl enable monit
sudo systemctl start monit

1.3 Verify Installation

Run the following to ensure Monit is active:

monit --version
sudo systemctl status monit
sudo monit status

2. Configure Monit

2.1 Basic Configuration

Edit /etc/monitrc to ensure basic settings are enabled:

Code snippet

set daemon 60              # Check interval in seconds
set logfile /var/log/monit.log
set statefile /var/lib/monit/state

# Optional: Web UI Configuration
set httpd port 2812 and
    use address localhost  # only accept connection from localhost
    allow localhost        # allow localhost to connect to the server and
    allow admin:monit      # require user 'admin' with password 'monit'

Test and reload after changes:

sudo monit -t
sudo monit reload

2.2 Create the Exec Script

We will create a single script that handles both Trigger (Failure) and Resolve (Recovery) events.

  • Create the file:
sudo nano /usr/local/bin/monit-to-callgoose.sh
  • Paste the following content:
#!/usr/bin/env bash

# --- CONFIGURATION ---
CALLGOOSE_URL="https://****.callgoose.com/v1/process?from=Monit&token=<YOUR_TOKEN>"
# ---------------------

RAW_MSG="$*"
HOSTNAME="$(hostname -f 2>/dev/null || hostname)"
SERVICE_NAME="${1:-unknown_service}"

# Determine Status based on the message content passed from Monit
# We assume the 'else' logic in Monit sends a positive message (e.g., 'recovered')
if echo "$RAW_MSG" | grep -Ei "not running|failed|down|not responding|space_high" >/dev/null; then
  STATUS="firing"
else
  STATUS="resolved"
fi

ID="${HOSTNAME}:${SERVICE_NAME}"
TITLE="Monit alert: ${SERVICE_NAME} on ${HOSTNAME}"
DESCRIPTION="$RAW_MSG"
TIMESTAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"

# JSON Escape the description to prevent payload errors
ESCAPED_DESC="$(echo "$DESCRIPTION" | sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/g' | tr -d '\n')"

PAYLOAD=$(cat <<EOF
{
  "status": "$STATUS",
  "id": "$ID",
  "title": "$TITLE",
  "description": "$ESCAPED_DESC",
  "source": "monit",
  "severity": "critical",
  "timestamp": "$TIMESTAMP",
  "monit_event": "$ESCAPED_DESC"
}
EOF
)

# Send to Callgoose
curl -sS -X POST "$CALLGOOSE_URL" \
  -H "Content-Type: application/json" \
  -d "$PAYLOAD"

exit 0
  • Make it executable:
sudo chmod +x /usr/local/bin/monit-to-callgoose.sh

2.3 Add Service Checks with Exec

You must use the else exec pattern so that Monit triggers the script when the issue is fixed.

Example 1 — Monitor Nginx

Code snippet

check process nginx with pidfile /run/nginx.pid
  start program = "/usr/sbin/service nginx start"
  stop program  = "/usr/sbin/service nginx stop"
  if not running then exec "/usr/local/bin/monit-to-callgoose.sh nginx not running"
  else if recovered then exec "/usr/local/bin/monit-to-callgoose.sh nginx recovered"

Example 2 — Monitor Disk Usage

Code snippet

check filesystem rootfs with path /
  if space usage > 80% then exec "/usr/local/bin/monit-to-callgoose.sh rootfs space_high"
  else if recovered then exec "/usr/local/bin/monit-to-callgoose.sh rootfs space_normal"

3. Obtain Callgoose SQIBS API Endpoint & Token

  • Log in to your Callgoose SQIBS dashboard.
  • Navigate to your Webhook/Process API settings.
  • Copy your endpoint URL and Token.
  • Edit the script created in step 2.2: sudo nano /usr/local/bin/monit-to-callgoose.sh
  • Replace <YOUR_TOKEN> with your actual token.

4. Configure API Filters in Callgoose SQIBS

To interpret the JSON sent by the script, set up the following filters in Callgoose:

4.1 Trigger Filter — Create Incident

  • Payload JSON key: "status"
  • Value contains: firing
  • Map incident with: "id"
  • Title from: "title"
  • Description from: "description" (or leave empty to receive whole payload)

4.2 Resolve Filter — Resolve Incident

  • Payload JSON key: "status"
  • Value contains: resolved
  • Incident mapped with: "id"

5. Trigger and Resolve Examples

5.1 Trigger Example — Failure Condition

Monit Event: Nginx stops running. Script Argument: nginx not running Result: Script detects keywords "not running", sets status to firing.

JSON Sent to Callgoose:

JSON

{
  "status": "firing",
  "id": "web01.example.com:nginx",
  "title": "Monit alert: nginx on web01.example.com",
  "description": "nginx not running",
  "source": "monit",
  "severity": "critical",
  "timestamp": "2025-11-25T07:00:00Z",
  "monit_event": "nginx not running"
}

5.2 Resolve Example — Recovery Condition

Monit Event: Nginx starts running again. Monit Logic: Hits the else if recovered block. Script Argument: nginx recovered Result: Script does not find failure keywords, sets status to resolved.

JSON Sent to Callgoose:

JSON

{
  "status": "resolved",
  "id": "web01.example.com:nginx",
  "title": "Monit alert: nginx on web01.example.com",
  "description": "nginx recovered",
  "source": "monit",
  "severity": "critical",
  "timestamp": "2025-11-25T07:05:00Z",
  "monit_event": "nginx recovered"
}

6. Testing the Integration

  • Set up the Filters: Ensure Callgoose is configured to look for status: firing and status: resolved.
  • Simulate Failure: Stop the service manually (e.g., sudo systemctl stop nginx).
  • Verify Log: Check /var/log/monit.log to see if the exec script ran.
  • Check Callgoose: Confirm an incident was created.
  • Simulate Recovery: Start the service (e.g., sudo systemctl start nginx) or wait for Monit to restart it.
  • Verify Resolution: Confirm the incident in Callgoose is marked as resolved.

7. Troubleshooting

If you face issues, check the following:

  • Script not executing:
  • Check permissions: ls -l /usr/local/bin/monit-to-callgoose.sh (must be executable).
  • Check script path in /etc/monitrc.
  • No incidents in Callgoose:
  • Verify the Token in the script variables.
  • Run the script manually to test network connectivity:
  • Bash
/usr/local/bin/monit-to-callgoose.sh test_service failed
  • No resolution:
  • Ensure your Monit check includes the else if recovered then exec... line.
  • Ensure the id generated in the JSON is identical for both trigger and resolve events.
  • Monit Syntax Errors:
  • Run sudo monit -t to validate config syntax.

8. Conclusion

You now have a complete, clean, script-based integration between Monit and Callgoose SQIBS. This setup ensures that every time Monit detects a failure or a recovery, your incident management system is automatically updated.

This documentation will guide you through the integration process, ensuring that your incidents are managed effectively within Callgoose SQIBS based on real-time alerts from Monit.

CALLGOOSE
SQIBS

Advanced Automation platform with effective On-Call schedule, real-time Incident Management and Incident Response capabilities that keep your organization more resilient, reliable, and always on

Callgoose SQIBS can Integrate with any applications or tools you use. It can be monitoring, ticketing, ITSM, log management, error tracking, ChatOps, collaboration tools or any applications

Callgoose providing the Plans with Unique features and advanced features for every business needs at the most affordable price.



Unique Features

  • 30+ languages supported
  • IVR for Phone call notifications
  • Dedicated caller id
  • Advanced API & Email filter
  • Tag based maintenance mode
Book a Demo

Signup for a freemium plan today &
Experience the results.

No credit card required