| 开发者 | cronheart |
|---|---|
| 更新时间 | 2026年11月13日 21:58 |
| PHP版本: | 8.2 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
start, success or fail ping around every run of each event you register. If the pings stop, or a job fails, cronheart alerts you by email, Telegram, Slack, Discord, Microsoft Teams, Google Chat, PagerDuty or a signed webhook.
Setup in 4 steps
cronheart_monitor( 'my_nightly_report', 'xxxxxxxx-…' );error_get_last() summary — the cronheart dashboard shows the cause without you tailing debug.log. This holds for runs through a page request, wp-cron.php, ALTERNATE_WP_CRON and WP-CLI's wp cron event run.cronheart_monitor() helper and CRONHEART_EVENT_<HOOK>_UUID constants, which still work. A constant overrides an assignment made on this screen; an assignment made on this screen overrides the helper.wp-config.php constants for production (CRONHEART_HEARTBEAT_UUID, CRONHEART_EVENT_<HOOK>_UUID), with admin-UI fallback for sites where editing wp-config.php is not practical.curl), which most hosts enable.WP_DEBUG and WP_DEBUG_LOG on, a ping that fails leaves one line in the debug log. A third-party filter that throws while the plugin reads its settings is caught too. If cronheart goes down for a day, your wp_schedule_event callbacks still run normally; you just stop seeing pings on the dashboard. When the plugin cannot send pings safely (the PHP cURL extension is missing, or the endpoint setting is one it does not accept), it sends none and shows an error notice in wp-admin instead.
External services
This plugin sends HTTP requests to cronheart.com in two distinct situations: the monitoring pings your scheduled jobs send, and the account-management calls the admin settings page makes. Both are opt-in: without configuration the plugin loads and does nothing — no telemetry, no usage statistics, no anonymous reports.
1. Monitoring pings (front end / WP-Cron). Sent on every scheduled WP-Cron run, but only when you supply a monitor UUID. The exact data sent per ping:
start / success / heartbeat pings. For a fail ping it holds the PHP error type, the file path and line, and the message of the fatal error or uncaught exception, or a one-line note that the event did not complete.User-Agent header (for example cron-monitor-php-sdk/1.9).https://cronheart.com/api/v1/.... Every such request carries the token as an Authorization: Bearer header and runs only while a logged-in administrator is on one of those screens — and, for the write actions below, only when that administrator clicks the control. Never on the front end, during WP-Cron, or in any other context. No token, no request. The calls are:
GET /api/v1/monitors — to populate the heartbeat picker, the "Your monitors" table, the per-event assignment dropdowns, and the Cronheart History monitor picker. Sends nothing beyond the token and paging parameters.GET /api/v1/account — to show your plan, monitor budget, and API rate-limit standing. Sends nothing beyond the token.POST /api/v1/monitors/<uuid>/pause (or /resume, /snooze, /unsnooze) — sent when you click a pause / resume / snooze / unsnooze button. Sends the monitor's UUID (in the path) and the action; snooze also sends the chosen duration (1 hour, 4 hours, 1 day, or 1 week).POST /api/v1/monitors — sent when you click "Auto-create & assign" for a recurring event on the Cronheart Events screen. Sends the event's hook name (as the monitor name), its schedule as an interval in seconds, the site timezone, and a grace period — all derived from the WP-Cron schedule — plus an idempotency key that is a SHA-256 hash of the site URL and the hook name (the URL itself is not sent), so a repeated click does not create a second monitor.GET /api/v1/channels — to populate the Cronheart Channels screen. Sends nothing beyond the token.POST /api/v1/channels/<id>/test — sent when you click "Send test" on a channel. This delivers a real notification to that channel's destination (your configured email, Telegram, Slack, Discord, Microsoft Teams, Google Chat, PagerDuty, or webhook), so it is the one management call with an effect outside cronheart.com. Sends only the channel id (in the path).POST /api/v1/channels/<id>/rotate-secret — sent when you click "Rotate secret" on a webhook channel. cronheart.com mints a new signing secret (shown to you once) and invalidates the previous one. Sends only the channel id (in the path); the new secret is shown in the page and never stored by the plugin.GET /api/v1/monitors/<uuid>/pings and GET /api/v1/monitors/<uuid>/alerts — to populate the Cronheart History screen for the monitor you select. Reads the most recent page only. Sends the monitor's UUID (in the path) and paging parameters.cron-monitor/php-sdk PHP package (also open source, MIT-licensed). Both projects are maintained independently.
curl), which most hosts enable. Without the extension the plugin sends no pings and shows an error notice in wp-admin.
cronheart.zip from a GitHub release.wp-config.php with define( 'CRONHEART_HEARTBEAT_UUID', 'xxxxxxxx-…' ); (recommended), or paste it under Settings → Cronheart in the WP admin.heartbeat ping shows on the cronheart dashboard shortly after. With the wp-config.php constant, the first ping arrives within five minutes. From then on it repeats every five minutes.define( 'CRONHEART_API_TOKEN', 'cmk_…' ); in wp-config.php to keep the account credential out of the database.add_action( 'plugins_loaded', function () { cronheart_monitor( 'my_nightly_report', 'xxxxxxxx-…' ); }, 1 );
The hook then emits start / success (or fail on a fatal / thrown exception) pings on every scheduled run.An uptime monitor checks that your site answers requests. It does not know whether WordPress ran its scheduled jobs: a site can serve every page while its backups, emails and cleanups are stalled. Cronheart watches the jobs themselves, and alerts you when the heartbeat stops or a monitored job fails.
Saving a monitor UUID under Settings queues one heartbeat for the next WP-Cron run, which on a site with visitors is the next page load. If you defined the UUID in wp-config.php instead, the first ping arrives within five minutes. After that the plugin pings every five minutes. On a site that has WP-Cron disabled, it happens on the next run of your system cron.
Two ways. With an API token saved under Settings → Cronheart, the Cronheart Events screen lists your recurring events and lets you assign a monitor to each, or create one in one click. Without a token, register a hook in code with cronheart_monitor( 'my_nightly_report', 'xxxxxxxx-…' );. A CRONHEART_EVENT_<HOOK>_UUID constant in wp-config.php then supplies or overrides that hook's UUID.
Yes. The Free plan on cronheart.com covers 20 monitors, needs no credit card and does not expire. Every plan, the free one included, has all notification channels and the REST API. Paid plans raise the monitor count and the API rate limit; see cronheart.com/pricing.
Yes. If you set define( 'DISABLE_WP_CRON', true ); and trigger wp-cron.php from a real system cron, the plugin's cronheart_heartbeat_tick event still fires on each run — the trigger mechanism is different, the action chain is the same. Running events with WP-CLI (wp cron event run --due-now) works as well, including the fail ping of an event that throws.
The plugin will retry up to twice (three attempts in all, each limited to 3 seconds) after a connection error or a server error, then give up; an answer that refuses the ping, such as a wrong monitor UUID, is not retried. Your scheduled callbacks still run normally — the plugin never raises an exception that could break the cron runner. The monitor on cronheart.com reports the missed run. With WP_DEBUG and WP_DEBUG_LOG on, each ping that fails also leaves one line in wp-content/debug.log (a ping the service refuses, such as one with a wrong monitor UUID, too), with the reason but without the monitor UUID or the full ping URL.
No — it is entirely optional. Paste a monitor UUID under Settings → Cronheart (or define it in wp-config.php) and the plugin works on any plan, including the free tier. A token only adds convenience: the settings page can then list your monitors and let you pick one from a dropdown instead of copying a UUID by hand. The token is an account-level credential, so for production prefer defining CRONHEART_API_TOKEN in wp-config.php over storing it in the database. The token features work on every plan, the free one included, but cronheart.com only lets an account with a verified email address create a token. If the token is refused or cronheart.com cannot be reached, the page shows a notice and falls back to manual UUID entry.
Sign in at cronheart.com, open the monitor you created, and copy the UUID shown under its name (it has a copy button), or take it from the address bar or from the end of the monitor's ping URL.
Nothing. The plugin catches every network / HTTP error from the SDK (and, with WP_DEBUG and WP_DEBUG_LOG on, writes one line per failed ping to the debug log) — your wp_schedule_event callbacks continue to run. You will stop seeing pings on the cronheart dashboard, and after the configured grace period cronheart sends you the down-alert. When cronheart comes back the next successful ping resolves the incident automatically.
No. The plugin sends a ping to cronheart only when you have configured a monitor UUID. The ping payload is the UUID, an optional short body excerpt (capped at 10 KB), and the SDK's User-Agent header. There is no anonymous-statistics beacon, no plugin-usage telemetry, no calls to any third-party analytics service.
Yes. Define CRONHEART_ENDPOINT in wp-config.php with the URL of your alternate deployment. For plain http:// endpoints (local development, private VPNs without TLS) also set CRONHEART_ALLOW_INSECURE_ENDPOINT to true. With both unset, the plugin pings the production cronheart.com over HTTPS. The API token is only ever sent over HTTPS, so with a plain http:// endpoint the settings screens fall back to manual UUID entry while pings keep working. An endpoint the plugin does not accept (one with no http:// or https:// scheme, or plain http:// without CRONHEART_ALLOW_INSECURE_ENDPOINT) stops all pings and shows an error notice in wp-admin; the plugin does not send them to cronheart.com instead. An empty CRONHEART_ENDPOINT means cronheart.com even when the cronheart_endpoint option is set, and a CRONHEART_ENDPOINT that is not a string is ignored.
The plugin shows this error notice on every wp-admin screen, to users who can manage options, when it cannot send pings safely; it then sends none. The notice names the cause. If the PHP cURL extension is not loaded on the server, ask your host to enable it. If the endpoint setting is not accepted, the notice says whether CRONHEART_ENDPOINT in wp-config.php or the cronheart_endpoint option holds it: use an https:// URL (a plain http:// URL also needs CRONHEART_ALLOW_INSECURE_ENDPOINT), or remove the setting to use cronheart.com. Until then your monitors alert that the jobs stopped checking in. The notice cannot be dismissed; it disappears on the next page load after the cause is fixed.
Open an issue on GitHub.
ref=wp-plugin label.wp plugin activate or deactivate, and no longer leaves a wrong current_action() for a monitored event's own callbacks.http:// or https:// scheme, or plain http:// without CRONHEART_ALLOW_INSECURE_ENDPOINT) now stops all pings and shows an error notice in wp-admin naming the constant or option that holds it. Before, the pings and the monitor UUIDs in them went to cronheart.com instead of the configured host.cronheart_allow_insecure_endpoint option now reads false, no, off and any unrecognised value as false, like the CRONHEART_ALLOW_INSECURE_ENDPOINT constant.WP_DEBUG and WP_DEBUG_LOG on, each failed ping writes one line to the debug log, including a ping the service refuses (such as one with a wrong monitor UUID). The line never holds a monitor UUID, an API token or a full URL.fail ping's body and the User-Agent header contain, the idempotency key of the auto-create call, WP-CLI runs, the retry rules and where to find a monitor's UUID.fail ping when it is run with wp cron event run (including --due-now), as hosts that drive WP-Cron from a system cron through WP-CLI do. Before, WordPress's own fatal-error handling ended the WP-CLI process before the plugin could send it, so the monitor received a start and no fail and stayed up. Runs through a page request, wp-cron.php or ALTERNATE_WP_CRON already sent it. The fail is sent once, and the WP-CLI command's output and exit code are unchanged.Retry-After the bundled SDK waits for it; after any other failure it waits a short fixed step; all waits of one ping stay within the ping timeout, and a 4xx answer is not retried. The ping timeout is now 3 seconds per attempt, so one ping takes at most about 12 seconds when the service keeps answering 503 slowly and about 10 seconds when it is unreachable; a ping sent inline in a visitor's request (ALTERNATE_WP_CRON, or a monitored hook fired by a page request) is held for that time. Requests that use your account API token keep one retry. Bundles cron-monitor/php-sdk 1.9. The FAQ answer about a blocked host no longer promises a debug.log line.cron-monitor/php-sdk to ^1.5.2. The SDK keeps the API token and monitor UUIDs out of its own stack-frame arguments, which an error tracker records, when an API call or a ping fails, and it refuses a monitor UUID with a trailing newline before any request is made. The plugin validates the UUIDs its own admin screens save, but a CRONHEART_HEARTBEAT_UUID or CRONHEART_EVENT_<HOOK>_UUID constant, a cronheart_monitor() call or a cronheart_monitor_map filter value reaches the SDK as written; with a trailing newline the older SDK sent the ping to a mangled address, which cronheart.com rejected. The ping still does not arrive, so the monitor keeps reporting missed runs until the value is fixed, but no request is sent; the WP-Cron run is unaffected either way.manage_options, boundary validation, no public endpoint) and the throwing management client; "Send test" delivers a real notification, and the rotated webhook secret is shown once and never stored by the plugin. The runtime ping path is unchanged.cron-monitor/php-sdk to ^1.4. It adds the typed channel-test delivery exception, so a failed test send reports "the destination rejected delivery" distinctly from other errors, and it keeps monitor UUIDs and API tokens out of its log lines and error text.http:// endpoint the management screens fall back to manual UUID entry; pings keep working.cronheart_monitor() helper, and only a CRONHEART_EVENT_<HOOK>_UUID constant overrides the assignment. Earlier notes said the helper took precedence.cronheart_monitor() helper and CRONHEART_EVENT_<HOOK>_UUID constants (both still work and still take precedence).manage_options, boundary validation, no public endpoint); the request hook is always validated against the discovered event set, and assigning a monitor is a local option write that needs no token. The live controls are token-gated like the heartbeat picker; without a token the screen is a read-only view.POST /api/v1/monitors), sent only when you click "Auto-create & assign".cron-monitor/php-sdk to ^1.1, which adds the account and monitor-lifecycle endpoints these features use.GET /api/v1/account) and write (POST /api/v1/monitors/<uuid>/{pause,resume,snooze,unsnooze}) calls; all remain wp-admin-only, token-gated, and triggered by an administrator's explicit action.cronheart_heartbeat_uuid option, so nothing changes about how pings are sent — only how you fill in the UUID.CRONHEART_API_TOKEN constant in wp-config.php.cron-monitor/php-sdk to ^1.0, which adds the authenticated management-API client the picker uses.Contributors: set to the slug owner. No code changes.Contributors: corrected, CLI binaries dropped from the zip. No behaviour changes.LICENSE, changelog cleanup. No behaviour changes.CRONHEART_ENDPOINT, CRONHEART_ALLOW_INSECURE_ENDPOINT) for staging, private or local deployments.cronheart_monitor() and constants, the Settings → Cronheart page, and the PHP fatal error in the fail ping.