Sends ICMP echo requests (pings) to the specified target.
Hostname or IP address to ping.
Optional
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`); }} Copy
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`); }}
Sends ICMP echo requests (pings) to the specified target.