monitor Command
pakyas monitor runs a command and reports it to Pakyas: a start ping before it runs, then a success or failure ping with the exit code when it ends.
# By slug, check ID, or public ID (needs an API key to resolve)pakyas monitor <CHECK> [FLAGS] -- <COMMAND> [ARGS...]
# By public ID (no API key, no API calls)pakyas monitor --public-id <UUID> [FLAGS] -- <COMMAND> [ARGS...]Everything after -- is the command to run. It is executed directly, not through a shell; use sh -c '...' if you need pipes, &&, or globbing inside the monitored command.
Examples
Section titled “Examples”# Basic usagepakyas monitor backup-db -- ./backup.sh
# Public ID: recommended for cron and CIpakyas monitor --public-id 550e8400-e29b-41d4-a716-446655440000 -- ./backup.sh
# Redirect the job's output; pakyas itself writes nothing to stdoutpakyas monitor db-dump -- pg_dump -h localhost mydb > backup.sql
# A pipeline, with the pipeline's failure reportedpakyas monitor db-dump -- bash -c 'set -o pipefail; pg_dump mydb | gzip > /backups/mydb.sql.gz'
# Environment variables for the jobpakyas monitor report-gen -- env REPORT_DAY=monday ./generate-report.shWhat It Does
Section titled “What It Does”- Resolves the check. With
--public-idnothing is looked up. With a slug, the public ID comes from the local cache if it was looked up in the last hour, otherwise from the API (falling back to the cached ID if the API can’t be reached). If no organization is configured, the CLI uses the organization of the API key. - Sends a start ping, with a run ID so the start and finish of this run are paired.
- Runs the command. Its stdout and stderr are streamed through live, and stdin is passed to it.
- Sends a completion ping with the measured duration: success when the exit code is 0, otherwise a failure ping for that exit code.
- Exits with the command’s exit code.
External monitors, if configured, receive the same start and completion events.
Monitoring never blocks the job. If the check can’t be resolved (unknown slug, no API key, API unreachable) or the start ping fails, pakyas prints a warning on stderr and still runs the command. The run is then reported with exit code 3 (see below).
Failure Body
Section titled “Failure Body”For a non-zero exit, the failure ping carries a text body:
Exit code: 2---<last part of stderr>If the process was killed by a signal, a Signal: N line follows the exit code. The body contains up to the last ~100 KB of stderr, or of stdout if stderr was empty; longer output is cut from the front and marked …(truncated). Pakyas shows the body in the dashboard and alerts.
How much of the body Pakyas keeps depends on your plan: the first 5 KB (Free), 25 KB (Developer) or 100 KB (Pro) of it, or all of it (Business, up to 250 KB). On the smaller plans that is the beginning of the captured output, so when a job writes a lot to stderr the final error message may be cut off. Keep stderr short and send verbose logs elsewhere.
| Flag | Env var | Description |
|---|---|---|
--public-id <UUID> | PAKYAS_PUBLIC_ID | Check public ID. Skips authentication and slug resolution. |
--no-external | PAKYAS_NO_EXTERNAL | Don’t notify external monitors |
--migration-mode | PAKYAS_MIGRATION_MODE | Keep the job’s exit code when Pakyas can’t be reached but an external monitor succeeded |
--external-timeout-ms <MS> | PAKYAS_EXTERNAL_TIMEOUT_MS | Timeout for each external monitor request (default 5000) |
The global flags also apply; -v prints each step to stderr.
PAKYAS_PUBLIC_ID takes precedence over a slug argument, so don’t set it globally in a shell where you monitor several checks.
Inline External Monitor Flags
Section titled “Inline External Monitor Flags”These add external monitors without a config file:
| Flag | Env var | Description |
|---|---|---|
--healthchecks-id <UUID> | PAKYAS_HEALTHCHECKS_ID | healthchecks.io check UUID |
--healthchecks-endpoint <URL> | HEALTHCHECKS_ENDPOINT | Custom healthchecks.io endpoint (default https://hc-ping.com) |
--cronitor-key <KEY> | PAKYAS_CRONITOR_KEY | Cronitor monitor key |
--cronitor-api-key <KEY> | CRONITOR_API_KEY | Cronitor API key (required with --cronitor-key) |
--cronitor-endpoint <URL> | - | Custom Cronitor endpoint (default https://cronitor.link) |
--webhook-url <URL> | - | Webhook URL; repeat for several webhooks |
pakyas monitor backup-db --healthchecks-id 0f1e2d3c-4b5a-4968-8776-655443322110 -- ./backup.sh
pakyas monitor backup-db \ --healthchecks-id 0f1e2d3c-4b5a-4968-8776-655443322110 \ --webhook-url https://hook1.example.com \ --webhook-url https://hook2.example.com \ -- ./backup.shInline monitors are added to the ones in external_monitors.toml. See External Monitors.
Environment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
PAKYAS_API_KEY | API key, needed only to resolve a slug |
PAKYAS_PUBLIC_ID | Same as --public-id |
PAKYAS_NO_EXTERNAL | Same as --no-external |
PAKYAS_MIGRATION_MODE | Same as --migration-mode |
PAKYAS_EXTERNAL_TIMEOUT_MS | Same as --external-timeout-ms |
PAKYAS_HEALTHCHECKS_ID | Same as --healthchecks-id |
HEALTHCHECKS_ENDPOINT | Same as --healthchecks-endpoint |
PAKYAS_CRONITOR_KEY | Same as --cronitor-key |
CRONITOR_API_KEY | Same as --cronitor-api-key |
EXTERNAL_WEBHOOK_URL | Webhook URL used when external_monitors.toml has no [targets.webhook] |
PING_URL | Ping base URL (default https://ping.pakyas.com) |
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| The command’s exit code | The run was recorded in Pakyas (0 for success) |
| 128 + N | The command was killed by signal N, for example 137 for SIGKILL |
| 3 | The run could not be recorded: the check could not be resolved or the completion ping failed. The command still ran. |
| 1 | The command could not be started, for example it was not found |
| 2 | Invalid pakyas arguments, or no command given |
With --migration-mode, a failed completion ping does not cause exit 3 if at least one external monitor received the result; the command’s own exit code is returned instead.
An exit code of 3 from pakyas monitor can also be your command’s own exit code 3. Check stderr for a Pakyas ping failed or Could not resolve check message to tell them apart.
See Also
Section titled “See Also”- ping - Send individual pings
- External Monitors - Run alongside healthchecks.io or Cronitor
- CLI Configuration - CI and cron setup