The MetricsView platform monitors Linux processes, including Java applications, Asterisk, and custom services, using a shell script. The script sends process status values to Dotcom-Monitor and triggers alerts when a monitored process stops running.

Use this approach to implement heartbeat monitoring on Linux systems when service-level monitoring is unavailable or when you need visibility into individual process status.

Prerequisites

Before configuring Linux process monitoring, ensure the following:

  • Access to a Linux server where the target process is running
  • Permission to create cron jobs
  • MetricsView licenses available on your account
  • A configured MetricsView Collector
  • The process name to monitor (for example: java, asterisk, or another service)

This setup requires available MetricsView tasks in your MetricsView package. If additional licenses are needed beyond your current subscription, they must be purchased separately.

How It Works

The monitoring workflow performs the following actions:

  1. A shell script checks whether a specified Linux process is running.
  2. The script sends:
    • 1 → Process is running
    • 0 → Process is not running
  3. MetricsView receives the value.
  4. Alert thresholds trigger notifications if the process stops.

This enables monitoring and alerting behavior similar to standard Dotcom-Monitor performance tasks.

Step-by-Step Guide

Step 1: Create a Custom MetricsView Collector

  1. Navigate to ManageMetricsView Collectors.
  2. Click New Collector.
  3. Configure the collector:
    • Enter a descriptive name.
    • Set Collector Type to Custom Collector.
  4. Copy the Collector ID.
  5. Save the collector.

You will use the Collector ID later in the monitoring script.

Step 2: Create a Custom Metrics Device for Process Status

  1. Open Device Manager.
  2. Click New Device.
  3. Choose Performance CountersCustom Metrics.
  4. Enter a meaningful device name.
  5. In the Error Thresholds section, set the Aggregate type to Minimum.
  6. Set Min. Threshold to 1.
  7. Copy the generated Task UID. The Task UID identifies the metric that receives process status values.
  8. Save the device configuration.

This device configuration triggers alerts when:

Process stopped → Script sends 0 → Alert generated

Step 3: Create the Linux Monitoring Script

Create a shell script on the Linux server:

nano /root/check_process.sh

Paste the following script:

#!/bin/bash

# Validate input
if [ "$#" -ne 3 ]; then
    echo "Usage: $0 <CollectorUID> <TaskUID> <process_name>"
    exit 1
fi

COLLECTOR_UID="$1"
TASK_UID="$2"
PROCESS_NAME="$3"

URL="https://wdc.dotcom-monitor.com/apiv1/tasks/post/$COLLECTOR_UID"

# Full paths required for cron
PGREP=/usr/bin/pgrep
CURL=/usr/bin/curl

# Check process status
if $PGREP -x "$PROCESS_NAME" > /dev/null
then
    STATUS=1
else
    STATUS=0
fi

# Build JSON payload
JSON_PAYLOAD=$(cat <<EOF
{
    "$TASK_UID": $STATUS
}
EOF
)

# Send metric to Dotcom-Monitor
$CURL -s -X POST "$URL" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
--max-time 10

exit $STATUS

Save and exit the editor.

Step 4: Make the Script Executable

Run:

chmod +x /root/check_process.sh

Step 5: Verify Metrics Are Being Received

Run the script manually using your values:

/root/check_process.sh YOUR_COLLECTOR_ID YOUR_TASK_UID PROCESS_NAME
  • Collector ID: Available under Manage > MetricsView Collectors.
  • Task UID: Found in the MetricsView device settings while editing the task.

Example:

/root/check_process.sh 4936df74a9d345f4aa754ab1d4e26cf8 117355baa9e8470eac602b48f79e3b23 asterisk

Expected behavior:

Process Status Value Sent
Running 1
Not running 0

If the script executes successfully, continue to scheduling.

Step 6: Schedule the Script Using Cron

Open cron:

crontab -e

Add:

* * * * * /root/check_process.sh YOUR_COLLECTOR_ID YOUR_TASK_UID PROCESS_NAME > /dev/null 2>&1

This executes the script every minute.

Example:

* * * * * /root/check_process.sh 4936df74a9d345f4aa754ab1d4e26cf8 117355baa9e8470eac602b48fd9e3b23 java > /dev/null 2>&1

Step 7: Verify Data Collection

After adding the cron job:

  1. Wait several minutes.
  2. From whithin your Dotcom-Monitori account, locate your MetricsView device.
  3. Open the relevant MetricsView report ( e.g., a Device Overview or Session Log report).
  4. Confirm incoming values.

Expected behavior:

Process Status Value Sent
Running 1
Not running 0

Continuous 1 values indicate successful monitoring.

Monitoring Multiple Processes

To monitor multiple processes independently and receive independent alerts for each process (for example, two Java applications), create:

  • Separate Custom MetricsView devices
  • Separate Task UIDs
  • Separate cron entries

Example:

* * * * * /root/check_process.sh COLLECTOR_UID TASK_UID_1 java1
* * * * * /root/check_process.sh COLLECTOR_UID TASK_UID_2 java2

Troubleshooting

If no data appears:

Verify cron execution

Run:

crontab -l

Confirm the cron entry exists.

Verify process detection

Test:

pgrep -x PROCESS_NAME

If no output appears, the process name may be incorrect.

Verify script permissions

Check:

ls -l /root/check_process.sh

Ensure executable permissions are present.

Test the script manually

Run the script directly before relying on cron.