Globalping Probe

repository·master·Indexed 41 days ago

https://github.com/jsdelivr/globalping-probe

A distributed network testing tool for running commands like ping, traceroute, and DNS lookups via community-hosted probes. Supports deployment via Docker and Podman, featuring automatic self-updates, resource scaling, and integration with the Globalping API for credit generation via adoption tokens.

Tokens
15.7K
Snippets
51
Records
63
Agent score
52%

What's inside Globalping Probe

  1. Set up a new Globalping probe using Docker

    master

    To join the Globalping network, run the official Docker container. The container supports both x86 and ARM architectures and requires no manual configuration beyond the initial run.

    If you have a Globalping account, you should use an adoption token via the GP_ADOPTION_TOKEN environment variable to generate credits and increase your rate limits.

    docker run -d --log-driver local --network host --restart=always --name globalping-probe globalping/globalping-probe
    
    # To include your adoption token:
    docker run -d --log-driver local --network host --restart=always --name globalping-probe -e GP_ADOPTION_TOKEN=XXX globalping/globalping-probe
  2. Adjust probe resource usage (CPU)

    master

    The probe's capacity scales with available CPU cores. While it is lightweight and usually runs optimally as is, you can limit the number of CPUs used by the container using the --cpuset-cpus Docker parameter.

    docker run -d --log-driver local --network host --restart=always --name globalping-probe --cpuset-cpus="0-2" globalping/globalping-probe
  3. Update the Globalping probe

    master

    The probe code updates automatically within the container. However, the container image itself is not updated automatically. To update to the latest container version, you must manually pull the new image, stop, and remove the existing container before running a new one.

    docker pull globalping/globalping-probe
    docker stop globalping-probe
    docker rm globalping-probe
    docker run -d --log-driver local --network host --restart=always --name globalping-probe globalping/globalping-probe
  4. Set up a new Globalping probe using Podman

    master

    For users opting for Podman, ensure you add the NET_RAW capability to allow the probe to perform network tests. You may also need to follow specific instructions to ensure the container starts automatically on boot and check logs for permission issues.

    sudo podman run --cap-add=NET_RAW -d --network host --restart=always --name globalping-probe globalping/globalping-probe
  5. Use the GitHub Packages mirror for Docker

    master

    If Docker Hub is inaccessible, you can pull the probe from the official GitHub Packages mirror. Note that ghcr.io does not currently support IPv6.

    docker run -d --log-driver local --network host --restart=always --name globalping-probe ghcr.io/jsdelivr/globalping-probe
  6. Understand DNS command failure sources

    master

    When a DNS command fails, the result includes a failureSource to help distinguish between network/resolver issues and internal probe issues.

    • resolver: The failure was caused by the DNS resolver (e.g., connection refused, timed out, or the resolver couldn't reach the address).
    • target: The query returned a private IP address, which is not allowed for non-ICANN targets.
    • internal: An unexpected error occurred within the probe execution logic.
  7. How the probe self-updates in Docker

    master

    When running as a Docker container, the entrypoint.sh script automatically attempts to self-update to the latest version before starting the probe.

    Update Workflow:

    1. Version Check: The script fetches the latest version from the jsDelivr API (https://data.jsdelivr.com/v1/packages/gh/jsdelivr/globalping-probe/resolved) or falls back to the GitHub API.
    2. Disk Space Check: An update is only attempted if there is at least 200 MB of available disk space on the root partition (/).
    3. Bundle Download: The script attempts to download the latest release tarball (globalping-probe.bundle.tar.gz) from three locations in order:
      • cdn.jsdelivr.net
      • fastly.jsdelivr.net
      • github.com
    4. Installation: The existing /app directory is replaced with the new version, and if a patch.sh script exists in the new bundle, it is executed.
    5. Execution: Once the update (if any) is complete, the probe is started using node /app/dist/index.js.
  8. HTTP request timing phases

    master

    HTTP measurements track the duration of several distinct phases of the request lifecycle. These timings are provided in milliseconds within the timings object of the output.

    • dns: Time taken for DNS resolution.
    • tcp: Time taken to establish the TCP connection.
    • tls: Time taken for the TLS handshake (only for HTTPS).
    • firstByte: Time from the end of the handshake/connection until the first byte of the response is received.
    • download: Time taken to download the response body.
    • total: The total time from the start of the measurement to completion.
  9. Understand Traceroute failure sources

    master

    The TracerouteCommand classifies failures into two main categories via the FailureSource type:

    • internal: The failure originated within the probe's environment (e.g., the traceroute process timed out but the target was reachable, or an internal execution error occurred).
    • target: The failure is related to the network path or the target itself (e.g., the target is unreachable, or the traceroute output indicates unanswered probes/unreachable upstream nodes).

    This distinction helps determine if a failed test is due to the probe's infrastructure or the network being tested.

  10. Automatic Node.js and Entrypoint Updates

    master

    The probe application includes built-in mechanisms for self-maintenance:

    Node.js Auto-updates

    If the current Node.js version does not match the WANTED_VERSION (currently v22.22.3), the probe attempts to update itself using nvm (Node Version Manager).

    Requirements for auto-update:

    • Memory: At least 250 MB of available memory.
    • Disk Space: At least 1000 MB of available disk space.
    • Environment: Must not be a hardware probe (detected via GP_HOST_HW or hardware inspection).

    If resources are insufficient, the probe will log a warning and skip the update.

    Entrypoint Updates

    The probe monitors its own entrypoint script. If a change is detected between the current entrypoint and the version in the package, the probe will replace the current script with a command to copy the new version and then restart the process.

  11. Understand the HopType data structure

    master

    A HopType object represents a single hop in a traceroute/MTR path. It contains both network identity and statistical performance data.

    Key Fields

    • resolvedAddress: The normalized IP address of the hop.
    • displayAddress: The address as it appeared in the raw output (may include scope IDs like %eth0).
    • resolvedHostname: The resolved DNS hostname.
    • asn: An array of Autonomous System Numbers (e.g., ['1234', '5678']).
    • stats: A HopStatsType object containing:
      • loss: Percentage of packet loss.
      • drop: Count of dropped packets.
      • rcv: Count of received packets.
      • total: Total packets sent.
      • avg: Average RTT.
      • stDev: Standard deviation of RTT.
      • jAvg: Average jitter.
      • min/max: Minimum and maximum RTT.
    • timings: An array of timing objects containing the RTT for specific sequences.