xk6-icmp
    Preparing search index...

    Function ping

    • Sends ICMP echo requests (pings) to the specified target.

      Parameters

      • target: string

        Hostname or IP address to ping.

      • Optionalopts: PingOptions

      Returns boolean

      true if the number of successful pings is greater than or equal to the threshold, otherwise false.

      import { ping } from "k6/x/icmp"

      export default function () {
      const host = "8.8.8.8"

      console.log(`Pinging ${host}:`);

      if (ping(host)) {
      console.log(`Host ${host} is reachable`);
      } else {
      console.error(`Host ${host} is unreachable`);
      }
      }