Skip to main content

Connectivity

c.Connectivity calls the API's Connectivity group. Whether the host reaches an address, by ICMP ping.

Methods​

MethodReturnsPermissionDescription
Ping(ctx, hostname, input)*Response[Collection[ConnectivityPingResult]]connectivity:executePing an address from the host.

Ping​

func (s *ConnectivityService) Ping(
ctx context.Context,
hostname string,
input ConnectivityPingInput,
) (*Response[Collection[ConnectivityPingResult]], error)

Ping an address from the host.

Sends three ICMP echo requests from the host and reports how many came back, and their round-trip times. A host that does not answer is 100% loss, not an error. It changes nothing, so it reports changed: false. On Linux the agent pings without root when net.ipv4.ping_group_range admits its group.

It sends POST /api/node/{hostname}/connectivity/ping, and needs the permission connectivity:execute.

The examples of the method's definition:

A host that answers, go run connectivity.go ping:

resp, err := c.Connectivity.Ping(ctx, target, client.ConnectivityPingInput{Address: "127.0.0.1"})

A host that does not answer, go run connectivity.go ping-2:

resp, err := c.Connectivity.Ping(ctx, target, client.ConnectivityPingInput{Address: "192.0.2.1"})

Types​

The fields of each type are the properties of its schema in the API's spec.

ConnectivityPingInput​

FieldTypeDescription
AddressstringThe IPv4 or IPv6 address to ping, or an @fact. reference that the agent resolves.

ConnectivityPingResult​

FieldTypeDescription
AvgRTTstringAverage round-trip time in milliseconds, with two decimals. Absent when no reply came back.
ChangedboolAlways false: a ping changes nothing on the host.
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
MaxRTTstringMaximum round-trip time in milliseconds, with two decimals. Absent when no reply came back.
MinRTTstringMinimum round-trip time in milliseconds, with two decimals. Absent when no reply came back.
PacketLossfloat64Percentage of packet loss.
PacketsReceivedintNumber of packets received.
PacketsSentintNumber of packets sent.
StatusRowStatusWhat happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.

RowStatus​

What happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.

A string, one of ok, failed, skipped, timeout.

Example​

examples/sdk/client/connectivity.go runs each example of this page. With no argument, it lists them.