How-to run Rust-based active checks on a monitored Linux host
Run Rust-based active checks like check_httpv2 directly on a monitored Linux host using MRPE for a simple setup or a local check wrapper when you need custom output formatting.
LAST TESTED ON CHECKMK 2.4.0P22
Overview
This guide shows how to run Rust-based active checks like check_httpv2 directly on a monitored Linux host using either MRPE (recommended) or a local check wrapper.
Background
By default, checks like check_httpv2 run as active checks from the Checkmk server.
In some cases, it makes more sense to run the check on the monitored host instead. For example:
The host has a different network path than the Checkmk server
The server cannot reach the target endpoint
You want to test connectivity from the host’s point of view
Because these checks are compiled Rust binaries, they can be copied to any Linux system and executed locally.
There are two supported ways to integrate them with the Checkmk agent:
MRPE (recommended)
Runs the plugin directly with no output modification requiredLocal check wrapper (alternative)
Wraps the binary in a script and reformats the output for the agent
MRPE is simpler and avoids formatting issues. Local checks are useful if you need custom logic or output control.
Step-by-step guide
Option 1: Use MRPE (recommend)
This is the simplest and most reliable method.
Configure MRPE
Edit:
/etc/check_mk/mrpe.cfg
Add:
check_httpv2 /usr/local/bin/check_httpv2 --url https://checkmk.com
Restart the agent
systemctl restart check-mk-agent
Verify in Checkmk
Run service discovery
Add the new service
Confirm it reports correctly
For full details, refer to the Official Documentation
Option 2: Use a local check wrapper (alternative)
Copy the check binary to the target host
From your Checkmk site, copy the binary to the monitored host:
scp /omd/sites/mysite/lib/nagios/plugins/check_httpv2 user@target-host:/usr/local/bin/You can use /tmp for testing, but for long-term use a permanent location like /usr/local/bin is better.
Test the binary locally
Log into the host and run the check manually:
check_httpv2 --url https://checkmk.com
You should see output similar to:
URL to test: https://checkmk.com/, Version: HTTP/2.0, Status: 200 OK | response_time=0.087865256s;;;0;10 time_http_headers=0.069728565s;;;; time_http_body=0.018136691s;;;; response_size=155144B;;;0;
URL to test: https://checkmk.com/
Method: GET
Version: HTTP/2.0
Status: 200 OK
Response time: 0.088 seconds
Page size: 155144 Bytes
User agent: checkmk-active-httpv2/2.4.0
Create a local check script
Create a script in the local checks directory:
/usr/lib/check_mk_agent/local/check_httpv2_local.sh
Example script:
#!/bin/bash
URL="https://checkmk.com"
SERVICE="http_checkmk_com"
BINARY="/usr/local/bin/check_httpv2"
OUTPUT=$("$BINARY" --url "$URL" 2>&1)
RC=$?
FIRSTLINE=$(printf '%s\n' "$OUTPUT" | head -n1)
LEFT=$(printf '%s\n' "$FIRSTLINE" | cut -d'|' -f1 | sed 's/[[:space:]]*$//')
RIGHT=$(printf '%s\n' "$FIRSTLINE" | cut -s -d'|' -f2- | sed 's/^[[:space:]]*//')
STATUS_TEXT=$(printf '%s\n' "$LEFT" | sed -n 's/.*Status: \(.*\)$/\1/p')
[ -z "$STATUS_TEXT" ] && STATUS_TEXT="$LEFT"
case "$RC" in
0) STATE=0 ;;
1) STATE=1 ;;
2) STATE=2 ;;
*) STATE=3 ;;
esac
if [ -n "$RIGHT" ]; then
echo "$STATE $SERVICE $RIGHT $STATUS_TEXT"
else
echo "$STATE $SERVICE - $STATUS_TEXT"
fi
Make it executable:
chmod +x /usr/lib/check_mk_agent/local/check_httpv2_local.sh
Verify the local check output
Run the script manually:
/usr/lib/check_mk_agent/local/check_httpv2_local.sh
You should see output like the following:
0 http_checkmk_com ... 200 OKThis is the format that the Checkmk agent expects.
Verify in Checkmk
Run a service discovery on the host
You should see a new service with the name you defined (for example
http_checkmk_com)Add the service and check that it reports correctly