Custom Command tests let you execute custom Bash or Python scripts on NetBeez Network Agents (hardware, virtual, cloud, container, and Linux software agents) to collect, chart, and alert on specialized numeric metrics. Custom Command tests are available both as recurring Scheduled Tests and as instant Ad-Hoc Tests. (Custom Command is not supported on Windows or macOS Remote Workers.)
In this article:
Script and Output Schema Requirements
Every Custom Command test pairs an executable script with an Output Schema that tells NetBeez which output keys to store and plot:
Required Shebang (Line 1): The script must start with either
#!/usr/bin/env bashor#!/usr/bin/env python(including#!/usr/bin/env python3).Script Size & Non-Interactive Execution: Scripts can contain up to
20,000characters and must run non-interactively within the configured Timeout (seconds) (1–120seconds, default30seconds).Standard Output Format (
key=value): Print one metric per line tostdoutinmetric_name=numeric_valueformat (integers or floating-point numbers). Any output lines that do not match a declared Metric name or do not contain a numeric value are ignored.Output Schema Mapping: Define at least one Metric and Unit pair (up to
64characters each). Click Add Output Schema Entry to capture multiple metrics from a single script, or click Remove to delete extra rows.Custom Error Reporting (
ERROR:): To surface a custom failure reason on the dashboard, print a line prefixed withERROR:(for example,echo "ERROR: Service endpoint unreachable"). NetBeez records the error on the run and displays it in the Results error banner, per-agent Breakdown table, and Ad-Hoc result card.
Creating a Scheduled Custom Command Test
Go to Scheduled Tests in the primary left sidebar and click Add Template.
Select Custom Command on the Choose Test Type step.
Details: Enter a Name and optional Description, then click Configure Test.
Configure Test:
Paste your script (beginning with
#!/usr/bin/env bashor#!/usr/bin/env python) into Custom Command.Enter each Metric key and display Unit under Output Schema (click Add Output Schema Entry for additional metrics).
Set Timeout (seconds) (
1–120, default30) and choose the Interface (Wi-Fi or Wired) for Wi-Fi Network Agents.
Source Agents: Select one or more Network Agents and/or Agent Groups.
Schedule: Set the cron frequency and select the Run Mode: Parallel (default), Serial, or Random with a Run Window.
Alerts: Optionally attach Scheduled Test Error alert profiles (which fire when
Xout of the lastYruns return an execution error; Custom Command skips Monitoring Conditions), then click Create Scheduled Test.
Running an Ad-Hoc Custom Command Test
Before scheduling a script across an entire Agent Group, you can validate its output on a single Network Agent from Ad-Hoc Tests (/ad_hoc, visible to Read Write and Administrator users):
Open Ad-Hoc Tests and click Custom Command in the Test Type bar.
Select an online, non-busy Network Agent in Source Agent (and choose Wi-Fi or Wired if applicable).
Paste your Custom Command script, set Timeout (seconds), and add matching Metric and Unit rows under Output Schema.
Click Run Custom Command Test. Extracted metrics (with units) and any
ERROR:messages render directly in the result card.
Example Bash and Python Scripts
Bash Example: Measuring Page Load Time with curl
Set Output Schema to Metric:load_time and Unit:seconds:
#!/usr/bin/env bash
load_time=$(curl -o /dev/null -s -w "%{time_total}\n" https://www.netbeez.net)
if [ $? -ne 0 ]; then
echo "ERROR: curl request failed"
exit 1
fi
echo "load_time=$load_time"
Python Example: Emitting Multiple Metrics
Add two Output Schema entries—tcp_handshake (ms) and payload_bytes (bytes):
#!/usr/bin/env python3
import socket
import timestart = time.monotonic()
with socket.create_connection(("example.com", 443), timeout=5) as sock:
elapsed_ms = round((time.monotonic() - start) * 1000, 2)print(f"tcp_handshake={elapsed_ms}")
print("payload_bytes=512")Tip: Always verify that required packages or CLI utilities exist on target Network Agents before deploying scripts across multiple agents, and browse the NetBeez Community for reusable script examples.


