### Installation Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Instructions for installing the Oh Dear CLI tool using Composer or Docker. ```APIDOC ## Installation > **Requires [PHP 8.4+](https://php.net/releases)** Via Composer ```shell composer global require ohdearapp/ohdear-cli ``` Make sure Composer's global bin directory is in your `PATH`. You can find the path by running: ```shell composer global config bin-dir --absolute ``` Verify the installation: ```shell ohdear --version ``` Via [Docker](https://docker.com) ```shell docker run --rm ghcr.io/ohdearapp/ohdear-cli:latest ``` ``` -------------------------------- ### Install Nova Tool via Composer Source: https://ohdear.app/docs/tools-and-sdks/our-laravel-nova-tool Install the nova-ohdear-tool package using Composer. ```bash composer require ohdearapp/nova-ohdear-tool ``` -------------------------------- ### Install Oh Dear PHP SDK Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Install the latest stable version of the Oh Dear PHP SDK using Composer. ```bash composer require ohdearapp/ohdear-php-sdk ``` -------------------------------- ### SOA Record Structure Example Source: https://ohdear.app/docs/features/dns-monitoring This example shows the SOA record for 'ohdear.app.', detailing zone authority information. ```dns ohdear.app. 3600 IN SOA ns3.combell.net. hostmaster.ohdear.app. 2020082810 10800 3600 604800 40000 ``` -------------------------------- ### Start Maintenance Window with CLI Source: https://ohdear.app/docs/features/how-to-configure-maintenance-windows Use this command to start a maintenance window. Replace `[site-id]` with your site's ID and `[seconds]` with the maximum duration. ```bash ohdear-cli maintenance period:start [site-id] [seconds] ``` -------------------------------- ### Start Immediate Maintenance Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Starts an immediate maintenance period for a monitor. Defaults to 60 minutes if no duration is specified. ```shell # Start immediate maintenance (default 60 minutes) ohdear start-maintenance --monitor-id=123 ``` -------------------------------- ### Install Oh Dear CLI Source: https://ohdear.app/docs/tools-and-sdks/cli-skill Install the Oh Dear CLI globally using Composer. Ensure you are logged in to your Oh Dear account afterwards. ```shell composer global require ohdearapp/ohdear-cli ohdear login ``` -------------------------------- ### Start Maintenance Period Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Starts a new maintenance period for a monitor immediately. ```APIDOC ## Start Maintenance Period ### Description Starts a new maintenance period for a monitor immediately. This is a shorthand for creating a maintenance period that lasts for a specified duration. ### Method ```php $ohDear->startMaintenancePeriod($monitorId, $durationInSeconds); ``` ### Parameters #### Path Parameters - **monitorId** (int) - Required - The ID of the monitor. - **durationInSeconds** (int) - Required - The duration of the maintenance period in seconds. ``` -------------------------------- ### Get DNS History Items for a Monitor Source: https://ohdear.app/docs/api/dns-records Example request to fetch DNS history items for a specific monitor. Ensure your API token is set as an environment variable. ```bash $ OHDEAR_TOKEN="your API token" $ curl https://ohdear.app/api/monitors/1/dns-history-items \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Verify CLI Installation Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Check if the Oh Dear CLI tool is installed correctly by verifying its version. ```shell ohdear --version ``` -------------------------------- ### Install Oh Dear CLI via Composer Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Install the CLI tool globally using Composer. Ensure Composer's global bin directory is in your system's PATH. ```shell composer global require ohdearapp/ohdear-cli ``` -------------------------------- ### Authentication Example Source: https://ohdear.app/docs/api/introduction This example demonstrates how to authenticate with the Oh Dear API using a Bearer token in the Authorization header. It shows a curl request to list all monitors. ```APIDOC ## Authenticate against the API Your API token is used to authenticate via the `Authorization: Bearer` header. The `/api/monitors` endpoint is hit to retrieve all monitors. The resulting response follows the same [JSON format](#response-data) described above -- each endpoint returns specific data, described in more detail on the [monitors](/docs/api/monitors.md) and [checks](/docs/api/checks.md) pages. ```bash $ OHDEAR_TOKEN="your API token" $ curl https://ohdear.app/api/monitors \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` ``` -------------------------------- ### Practical Example of CheckResult Usage Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk A practical example showing how to use the checkResult() method and its helpers to determine the status of a monitor. ```php use OhDear\PhpSdk\Enums\CheckType; $summary = $ohDear->checkSummary($monitorId, CheckType::Uptime); if ($summary->checkResult()?->isUp()) { echo "Monitor is reachable\n"; } if ($summary->checkResult()?->isWarning()) { echo "Partial connectivity issue detected\n"; } if ($summary->checkResult()?->isDown()) { echo "Monitor is down\n"; } ``` -------------------------------- ### NS Record Example for Subdomain Delegation Source: https://ohdear.app/docs/features/dns-monitoring This example demonstrates delegating DNS records for a subdomain ('sub.domain.ohdear.app.') to different nameservers. ```dns sub.domain.ohdear.app. 3600 IN NS ns1.otherprovider.tld. sub.domain.ohdear.app. 3600 IN NS ns2.otherprovider.tld. ``` -------------------------------- ### Uptime Percentage Response Example Source: https://ohdear.app/docs/api/uptime This is an example of the JSON response structure for uptime percentages, showing the datetime and uptime percentage for each interval. ```json [ {"datetime": "2018-01-01 00:00:00", "uptime_percentage": 100}, {"datetime": "2018-01-01 01:00:00", "uptime_percentage": 99.76}, {"datetime": "2018-01-01 02:00:00", "uptime_percentage": 100}, {"datetime": "2018-01-01 03:00:00", "uptime_percentage": 98.34}, "..." ] ``` -------------------------------- ### Login Link Response Example Source: https://ohdear.app/docs/api/reseller Example of the JSON response when generating a login link, including the URL and its expiration time. ```json { "login_url": "https://ohdear.app/reseller-login/98765/12345?expires=1640995200&signature=abc123...", "valid_until": "2025-01-01 12:05:00" } ``` -------------------------------- ### Expanded Monitor URL Example Source: https://ohdear.app/docs/features/uptime-and-performance-monitoring This example shows how the monitor URL with the `$OH_DEAR_TIMESTAMP` variable is expanded during an actual check, demonstrating the cache-busting effect. ```url https://your-site.com/?cb=20260516112100123 ``` -------------------------------- ### Example User Info API Request Source: https://ohdear.app/docs/api/user-info This example demonstrates how to make a request to the user info endpoint using curl. Ensure your OHDEAR_TOKEN is set as an environment variable. ```bash $ OHDEAR_TOKEN="your API token" $ curl https://ohdear.app/api/me \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Start Maintenance Period (Shorthand) Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Starts a new maintenance period for a monitor immediately, lasting for a specified duration in seconds. This is a shorthand for creating a maintenance period. ```php $ohDear->startMaintenancePeriod( 1, // Monitor ID 120, // Amount of seconds ); ``` -------------------------------- ### NS Record Example for Domain Delegation Source: https://ohdear.app/docs/features/dns-monitoring This example shows how NS records delegate DNS management for 'ohdear.app.' to specific nameservers. ```dns ohdear.app. 3600 IN NS ns4.combell.net. ohdear.app. 3600 IN NS ns3.combell.net. ``` -------------------------------- ### Install Oh Dear CLI via Docker Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Run the Oh Dear CLI tool using Docker without a global installation. ```shell docker run --rm ghcr.io/ohdearapp/ohdear-cli:latest ``` -------------------------------- ### SRV Record Example for Service Discovery Source: https://ohdear.app/docs/features/dns-monitoring This example demonstrates an SRV record for the SIP service over TCP, helping clients discover connection settings. ```dns _sip._tcp.example.com. 86400 IN SRV 0 5 5060 sipserver.example.com. ``` -------------------------------- ### PTR Record Example Source: https://ohdear.app/docs/features/dns-monitoring This example illustrates a PTR record, mapping an IP address to a domain name, often used for spam prevention. ```dns 217.19.225.103.in-addr.arpa. 3600 IN PTR ohdear.app. ``` -------------------------------- ### Detected Certificate Response Example Source: https://ohdear.app/docs/api/certificate-health This is an example of the JSON response when retrieving a detected certificate. It contains the certificate's fingerprint, details, and metadata. ```json { "id": 123, "monitor_id": 1, "fingerprint": "abcd1234567890abcd1234567890abcd12345678", "certificate_details": { "issuer": "Let's Encrypt Authority X3", "domain": "example.com", "additional_domains": [ "www.example.com" ], "valid_from": "2023-10-01T12:00:00Z", "valid_until": "2024-01-01T12:00:00Z", "days_until_expiration": 45, "signature_algorithm": "sha256WithRSAEncryption", "is_valid": true, "is_expired": false }, "created_at": "2023-10-01T12:30:00Z", "updated_at": "2023-10-01T12:30:00Z" } ``` -------------------------------- ### Starting maintenance immediately Source: https://ohdear.app/docs/api/maintenance-windows Starts an immediate maintenance window for a specified monitor, suppressing notifications until the window ends. You can optionally specify the duration and a name for the window. ```APIDOC ## POST /api/monitors/{monitorId}/start-maintenance ### Description Starts maintenance for a monitor right now. We'll suppress notifications until the window ends. ### Method POST ### Endpoint /api/monitors/{monitorId}/start-maintenance ### Parameters #### Path Parameters - **monitorId** (string) - Required - The ID of the monitor to start maintenance for. #### Request Body - **stop_maintenance_after_seconds** (integer, optional) -- how long the window lasts in seconds. Minimum `5`, default `3600` - **name** (string, optional) -- a label for this maintenance window ### Response #### Success Response (200) - Returns the [maintenance period object](#maintenance-period-response-fields). ``` -------------------------------- ### Example Down-Message with Placeholder Source: https://ohdear.app/docs/status-pages/create-your-first-oh-dear-status-page This example shows how to use the :monitor placeholder in a down-message to automatically include the affected website's URL. This message will be posted on status pages when a monitored website goes down. ```text We are aware :monitor seems to be down. Our engineers are working on the fix. ``` -------------------------------- ### Start an immediate maintenance period Source: https://ohdear.app/docs/api/introduction/swagger Starts an immediate maintenance period for a monitor, with a default duration of 60 minutes. Authentication is via the HTTP Authorization Header using a Bearer token. ```APIDOC ## POST /monitors/{monitorId}/start-maintenance ### Description Start an immediate maintenance period (default 60 minutes). ### Method POST ### Endpoint /monitors/{monitorId}/start-maintenance ### Parameters #### Path Parameters - **monitorId** (string) - Required - The ID of the monitor. ``` -------------------------------- ### Install Oh Dear CLI Skill Source: https://ohdear.app/docs/tools-and-sdks/using-ai-with-oh-dear Install the CLI skill to enable AI assistants to use the Oh Dear CLI tool. This provides access to all Oh Dear API endpoints. ```shell ohdear install-skill ``` -------------------------------- ### Get Help for a Specific Command Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool View detailed parameter information for any command, such as 'get-monitor'. ```shell ohdear get-monitor --help ``` -------------------------------- ### Example JSON Response for /api/monitors Source: https://ohdear.app/docs/api/introduction This is an example payload for the /api/monitors endpoint, which lists all configured monitors. The response structure includes a 'data' array containing monitor objects, each with an 'id', 'url', and other relevant details. ```json { "data": [ { "id": 1, "url": "https://yoursite.tld", "..." }, { "id": 2, "url": "https://yourothersite.tld", "..." } ] } ``` -------------------------------- ### Downtime Period Response Example Source: https://ohdear.app/docs/api/uptime This JSON structure represents a single downtime period, including its ID, start and end times, and notes. ```json { "data": [ { "id": 1, "started_at": "2018-01-01 15:00:00", "ended_at": "2018-01-01 15:07:00", "notes_html": "We contacted our provider and they fixed the issue.", "notes_markdown": "We contacted our provider and they fixed the issue." } ] } ``` -------------------------------- ### On-Demand Maintenance Window Example Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Demonstrates creating a short, on-demand maintenance window for deployments, then stopping it afterwards. ```php // Create a 10-minute maintenance period $ohDear->startMaintenancePeriod(1, 600); // Your deployment code here // ... // Stop the maintenance period $ohDear->stopMaintenancePeriod(1); ``` -------------------------------- ### Cron Expression Example: Every 4 Hours Source: https://ohdear.app/docs/faq/what-is-a-cron-job-expression This cron expression runs a command every 4 hours, specifically at the start of the hour (e.g., 00:00, 04:00, 08:00). ```text 0 */4 * * * logrotate ``` -------------------------------- ### Get Downtime Data Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Fetches downtime periods for a given monitor within a specified date range. The `downtime()` method returns an array of `DowntimePeriod` objects, detailing the start and end times of each downtime incident. ```APIDOC ## downtime ### Description Fetches downtime periods for a given monitor within a specified date range. The `downtime()` method returns an array of `DowntimePeriod` objects, detailing the start and end times of each downtime incident. ### Method ```php $ohDear->downtime($monitorId, $start, $end); ``` ### Parameters #### Path Parameters - **monitorId** (int) - Required - The ID of the monitor. - **start** (string) - Required - The start date in `Y-m-d H:i:s` format. - **end** (string) - Required - The end date in `Y-m-d H:i:s` format. ### Response #### Success Response Returns an array of `OhDear\PhpSdk\Dto\DowntimePeriod` instances. - **startedAt** (string) - The date time when downtime detection began. - **endedAt** (string) - The date time when the monitor was detected as back online. ``` -------------------------------- ### Instantiate Oh Dear PHP SDK Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Create an instance of the Oh Dear SDK by passing your API key. Ensure you have an API key from the Oh Dear platform. ```php $apiKey = "iK4YfZe2i1RAe22tKP4xejGKDZP .... "; $ohDear = new OhDear\PhpSdk\OhDear($apiKey); ``` -------------------------------- ### HTTP Uptime Result Request Fields Source: https://ohdear.app/docs/tools-and-sdks/webhooks Example of request fields recorded for HTTP uptime checks, including checkUrl, requestHeaders, and requestPayload. ```json "checkUrl":"https:\/\/yoursite.tld\/webhooks\/ping", "requestHeaders":{ "Content-Type":"application\/json", "X-Request-Id":"7b9a5e84-2c9c-4a2b-9c2d-1b0d8f5a3e21" }, "requestPayload":[ {"name":"event","value":"heartbeat"}, {"name":"sent_at","value":"20191001092130000"} ] ``` -------------------------------- ### Fetch Detailed Results for a Specific Run Source: https://ohdear.app/docs/api/check-history To get detailed results for a particular run, append `?run_id={id}` to the relevant check type's endpoint. This example shows how to fetch details for a broken links check. ```http GET /api/broken-links/{monitorId}?run_id=123 ``` -------------------------------- ### Get Uptime Data with Oh Dear PHP SDK Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Retrieve uptime data for a specific monitor within a date range. Requires monitor ID, start and end dates, and an UptimeSplit enum value. Returns an array of Uptime DTOs. ```php use OhDear\PhpSdk\Enums\UptimeSplit; $ohDear->uptime($monitorId, $start, $end, UptimeSplit::Hour); ``` -------------------------------- ### Partial Connectivity Webhook Payload Source: https://ohdear.app/docs/tools-and-sdks/webhooks This JSON payload represents a webhook notification for partial connectivity. Check the `run.result` field for 'warning' to distinguish it from a full recovery ('succeeded'). This example shows a primary checker failing while a secondary checker succeeds. ```json { "type":"[monitor-type]UptimeCheckRecoveredNotification", "date_time":"20180312092737", "monitor":{ "id":1, ... /* See above */ }, "run":{ "id":19830466, "check_id":10988, "parameters":null, "result":"warning", "result_payload":{ "checkerResult1":{ "checkerServer":{ "name":"uptime-checker-paris", "city":"Paris", "country":"France", "ip":"45.32.146.84" }, "checkUrl":"https:\/\/yoursite.tld\/", "response":[ ], "lookForString":"", "lookForStringFound":true, "error":{ "type":"connectionError", "errorNumber":6, "description":"Could not resolve host: yoursite.tld" }, "statistics":{ "url":"https:\/\/yoursite.tld\/", "http_code":0 } }, "checkerResult2":{ "checkerServer":{ "name":"uptime-checker-bangalore", "city":"Bangalore", "country":"India", "ip":"139.59.75.39" }, "checkUrl":"https:\/\/yoursite.tld\/", "response":{ "code":200, "code_phrase":"OK", "protocol":"1.1", "headers":{ "Server":["nginx"], "Content-Type":["text\/html; charset=UTF-8"] } }, "lookForString":"", "lookForStringFound":true, "error":[ ], "statistics":{ "url":"https:\/\/yoursite.tld\/", "http_code":200, "total_time":0.110265 } } } } } ``` -------------------------------- ### Example Reseller API Request Source: https://ohdear.app/docs/api/reseller Demonstrates how to make a request to the reseller API to fetch managed teams. Ensure your OHDEAR_TOKEN is set as an environment variable. ```bash $ OHDEAR_TOKEN="your API token" $ curl https://ohdear.app/api/reseller/11111/managed-teams \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Create a New Monitor with Oh Dear PHP SDK Source: https://ohdear.app/docs/tools-and-sdks/the-oh-dear-php-sdk Add a new monitor using the `createMonitor()` method, specifying URL, type, and team ID. Default checks are applied based on the monitor type. ```php $ohDear->createMonitor([ 'url' => 'https://yourbrandnewsite.tld', 'type' => 'http', 'team_id' => $yourTeamId, ]); ``` -------------------------------- ### Laravel: Get Current Unix Timestamp Source: https://ohdear.app/docs/faq/why-is-my-application-health-check-reporting-old-results Use `now()->timestamp` to get the current Unix timestamp in seconds in Laravel. ```php // Current timestamp $timestamp = now()->timestamp; ``` -------------------------------- ### Domain Issues Fixed Notification Source: https://ohdear.app/docs/tools-and-sdks/webhooks This notification is sent when previously detected domain issues have been resolved, for example, if the domain has been renewed. ```APIDOC ## Domain Issues Fixed Notification ### Description This webhook event is triggered when domain issues that were previously reported have been resolved. ### Event Type domainIssuesFixedNotification ### Payload Structure ```json { "type": "domainIssuesFixedNotification", "uuid": "", "date_time": "20220414120000", "run": { "id": 12345678902, "result": "succeeded", "check_id": 123456, "ended_at": "2022-04-14T12:00:00.000000Z", "created_at": "2022-04-14T12:00:00.000000Z", "parameters": null, "started_at": null, "updated_at": "2022-04-14T12:00:00.000000Z", "result_payload": [], "check": { "id": 123456, "type": "domain", "enabled": true, "monitor_id": 1, "latest_run_result": "succeeded", "latest_run_ended_at": "2022-04-14T12:00:00.000000Z" } }, "monitor": { "id": 1 } } ``` ``` -------------------------------- ### PHP: Get Current Unix Timestamp Source: https://ohdear.app/docs/faq/why-is-my-application-health-check-reporting-old-results Use `time()` to get the current Unix timestamp in seconds in PHP. ```php // Current timestamp $timestamp = time(); ``` -------------------------------- ### Create a monitor Source: https://ohdear.app/docs/api/introduction/swagger Creates a new monitor. ```APIDOC ## POST /monitors ### Description Create a monitor ### Method POST ### Endpoint /monitors ``` -------------------------------- ### Fetch HTTP Uptime Metrics Source: https://ohdear.app/docs/api/uptime-metrics Example of how to retrieve HTTP uptime metrics for a specific monitor. Ensure your API token is set and specify the desired time range and grouping. ```bash $ OHDEAR_TOKEN="your API token" $ curl "https://ohdear.app/api/monitors/1/http-uptime-metrics?filter[start]=20240419132501&filter[end]=20240420132501&filter[group_by]=minute" \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Go: Get Current Unix Timestamp Source: https://ohdear.app/docs/faq/why-is-my-application-health-check-reporting-old-results Use `time.Now().Unix()` to get the current Unix timestamp in seconds in Go. ```go timestamp := time.Now().Unix() ``` -------------------------------- ### Example DNS TXT Records Source: https://ohdear.app/docs/features/dns-monitoring Demonstrates the structure of TXT records for SPF, Google Site Verification, and Have I Been Pwned verification. ```dns ohdear.app. 3600 IN TXT "v=spf1 a mx include:email.freshdesk.com -all" ohdear.app. 3600 IN TXT "google-site-verification=jIujgqEVQyUbkwSXgE4227mQZPqdrcHsPymDWvt4pwI" ohdear.app. 3600 IN TXT "have-i-been-pwned-verification=8c3c98faa5fbef9d7bce7b1dbb898d1d" ``` -------------------------------- ### Python: Get Current Unix Timestamp Source: https://ohdear.app/docs/faq/why-is-my-application-health-check-reporting-old-results Use `int(time.time())` to get the current Unix timestamp in seconds in Python. ```python import time timestamp = int(time.time()) ``` -------------------------------- ### Add a monitor through the API Source: https://ohdear.app/docs/api/monitors Create a new monitor and start monitoring immediately. The response includes the newly created monitor object with all checks set to 'pending'. ```APIDOC ## POST /api/monitors ### Description Create a new monitor and start monitoring immediately. ### Method POST ### Endpoint /api/monitors ### Parameters #### Request Body - **url** (string) - Required - The URL/hostname to monitor - **team_id** (integer) - Required - The team this monitor belongs to. See [user info](/docs/api/user-info.md) to find your teams. - **type** (string) - Required - "http" for websites, "ping" for ICMP ping, "tcp" for TCP port, or "ai" for AI verification - **checks** (array) - Optional - Array of [check types](/docs/api/data-types.md#check-types) to enable. If omitted, the default checks for the monitor type will be enabled. ### Request Example ```json { "url": "https://example.com", "team_id": "1", "type": "http" } ``` ### Response #### Success Response (200) - **monitor object** - Contains details of the created monitor with all checks set to "pending". See [get a specific monitor](#get-a-specific-monitor) for the structure. ``` -------------------------------- ### Example Request to List Application Health Checks Source: https://ohdear.app/docs/api/application-health Use this command to fetch a list of all application health checks for a specific monitor. Ensure your OHDEAR_TOKEN is set. ```bash $ OHDEAR_TOKEN="your API token" $ curl https://ohdear.app/api/monitors/1/application-health-checks \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Verify Response Header with Any Value Source: https://ohdear.app/docs/features/uptime-and-performance-monitoring This example demonstrates how to check for the presence of a specific response header, regardless of its value, using a wildcard. It's useful for confirming that certain headers are set. ```text laravel-responsecache: * ``` -------------------------------- ### TypeScript/JavaScript: Get Current Unix Timestamp Source: https://ohdear.app/docs/faq/why-is-my-application-health-check-reporting-old-results Use `Math.floor(Date.now() / 1000)` to get the current Unix timestamp in seconds in TypeScript/JavaScript. ```typescript // Current timestamp const timestamp: number = Math.floor(Date.now() / 1000); ``` -------------------------------- ### Start Maintenance Window via API Source: https://ohdear.app/docs/features/how-to-configure-maintenance-windows Initiate a maintenance window using a cURL request to the Oh Dear API. Ensure the `OHDEAR_TOKEN` environment variable is set. ```bash $ OHDEAR_TOKEN="your API token" $ curl -X POST https://ohdear.app/api/monitors/1/start-maintenance \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Example response with all three monitor types Source: https://ohdear.app/docs/api/monitors This JSON response demonstrates the structure for HTTP, Ping, and TCP monitor types, including their specific uptime check settings. ```json { "data": [ { "id": 1, "type": "http", "url": "https://freek.dev", "summarized_check_result": "succeeded", "uptime_check_settings": { "location": "paris", "http_verb": "get", "timeout": 5, "valid_status_codes": ["2*"], "..." }, "..." }, { "id": 2, "type": "ping", "url": "spatie.be", "summarized_check_result": "succeeded", "uptime_check_settings": { "location": "paris", "ttl": 64, "count": 5, "packet_size_in_bytes": 56, "acceptable_packet_loss_percentage": 0, "acceptable_average_response_time_in_ms": 400, "..." }, "..." }, { "id": 3, "type": "tcp", "url": "smtp.gmail.com:3306", "summarized_check_result": "succeeded", "uptime_check_settings": { "location": "paris", "tcp_send_string": "", "timeout_in_ms": 1000, "look_for_string_in_welcome_message": "", "..." }, "..." } ], "links": { "..." }, "meta": { "..." } } ``` -------------------------------- ### DNS CAA Record Examples Source: https://ohdear.app/docs/features/dns-monitoring Examples of DNS CAA records demonstrating different flags and tags for certificate authority authorization and notification. ```dns ohdear.app. 3600 IN CAA 0 iodef "mailto:support@ohdear.app" ohdear.app. 3600 IN CAA 0 issue "letsencrypt.org" ohdear.app. 3600 IN CAA 0 issuewild "letsencrypt.org" ``` -------------------------------- ### Example MX Null Record for example.com Source: https://ohdear.app/docs/features/dns-monitoring Shows the MX null record configuration for the example.com domain, used to prevent unwanted email delivery attempts. ```dns example.com. 86400 IN MX 0 . ``` -------------------------------- ### List and Create Tags Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Lists all available tags and creates a new tag with a specified name and color. ```shell # List and create tags ohdear list-tags ohdear create-tag --field name="Production" --field color="#ff0000" ``` -------------------------------- ### Linux Crontab Entry Example Source: https://ohdear.app/docs/faq/what-are-cron-jobs-and-what-can-you-do-with-them A single line in a crontab file pairs a schedule with a command. This example shows a job scheduled to run weekly. ```bash 30 3 * * 1 /home/user/scripts/weekly_backup.sh ``` -------------------------------- ### Create Scheduled Maintenance Period Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Creates a new maintenance period with specified start and end times. Requires monitor ID, start time, and end time. ```shell # Create a scheduled maintenance period ohdear create-maintenance-period --field monitor_id=123 --field starts_at="2026-03-01 00:00:00" --field ends_at="2026-03-01 06:00:00" ``` -------------------------------- ### Example DNS CNAME Record Source: https://ohdear.app/docs/features/dns-monitoring This is an example of a DNS CNAME record, which acts as an alias for another domain name. It forwards lookups for the host to the specified domain name. ```dns www.ohdear.app. 60 IN CNAME ohdear.app. ``` -------------------------------- ### Example Request for Check Summary Source: https://ohdear.app/docs/api/check-summary Demonstrates how to make a curl request to the check summary endpoint. Ensure you replace 'your API token' with your actual token and specify the correct monitor ID and check type. ```bash $ OHDEAR_TOKEN="your API token" $ curl https://ohdear.app/api/monitors/99/check-summary/uptime \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Example API Request Source: https://ohdear.app/docs/api/broken-links-crawled-urls Demonstrates how to make a request to the broken links API using cURL. Ensure your API token is set as an environment variable. ```bash $ OHDEAR_TOKEN="your API token" $ curl https://ohdear.app/api/broken-links/1 \ -H "Authorization: Bearer $OHDEAR_TOKEN" \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Health Check Results JSON Example Source: https://ohdear.app/docs/features/application-health-monitoring#health-check-results-format This is an example of the JSON response your application should return for health check results. Ensure the `finishedAt` timestamp is within the last 10 minutes. ```json { "finishedAt": "1638879833", "checkResults": [ { "name": "UsedDiskSpace", "label": "Used Disk Space", "status": "failed", "notificationMessage": "The disk is almost full (91% used)", "shortSummary": "91%", "meta": { "disk_space_used_percentage": 91 } }, { "name": "Redis", "label": "redis", "status": "ok", "notificationMessage": "", "shortSummary": "Available", "meta": [] } ] } ``` -------------------------------- ### Example Log Entry from Oh Dear Crawler Source: https://ohdear.app/docs/faq/what-is-the-oh-dear-crawler-doing-in-my-logs An example of an access log entry showing a request from the Oh Dear crawler. This can help identify its presence in your server logs. ```log 10.0.1.1 - - [28/Nov/2025:08:17:48 +0000] "GET / HTTP/1.1" 200 845 "-" "OhDear.app (+https://ohdear.app/docs/features/broken-links-detection)" ``` -------------------------------- ### List All Available Commands Source: https://ohdear.app/docs/tools-and-sdks/our-cli-tool Display a list of all commands supported by the Oh Dear CLI tool. ```shell ohdear list ``` -------------------------------- ### Simulate HTTP Form Submission with POST Source: https://ohdear.app/docs/features/configure-your-oh-dear-settings-per-monitor Use this configuration to simulate a POST call to a web form. Set the method to POST and include any necessary form fields in the request data. ```bash $ curl --request POST https://yoursite.tld/form \ -d "name=your first name&order_id=654" ```