netinfo

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package netinfo collects a read-only snapshot of host network interfaces.

Index

Constants

View Source
const (
	WarningHostnameUnavailable   = "hostname_unavailable"
	WarningInterfacesUnavailable = "interfaces_unavailable"
	WarningAddressesUnavailable  = "addresses_unavailable"
	WarningCountersUnavailable   = "counters_unavailable"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	CIDR   string `json:"cidr"`
	Family string `json:"family"`
	Scope  string `json:"scope"`
	Zone   string `json:"zone,omitempty"`
}

Address describes one IP address assigned to an interface.

type Interface

type Interface struct {
	Index             int       `json:"index,omitempty"`
	Name              string    `json:"name"`
	Up                bool      `json:"up"`
	Running           bool      `json:"running"`
	Loopback          bool      `json:"loopback"`
	PointToPoint      bool      `json:"point_to_point,omitempty"`
	MTU               int       `json:"mtu,omitempty"`
	Addresses         []Address `json:"addresses"`
	CountersAvailable bool      `json:"counters_available"`
	RXBytes           uint64    `json:"rx_bytes,omitempty"`
	TXBytes           uint64    `json:"tx_bytes,omitempty"`
}

Interface describes one host network interface and its cumulative counters.

type Snapshot

type Snapshot struct {
	Available     bool        `json:"available"`
	CollectedTime int64       `json:"collected_time"`
	Hostname      string      `json:"hostname,omitempty"`
	OS            string      `json:"os"`
	Arch          string      `json:"arch"`
	Interfaces    []Interface `json:"interfaces"`
	Warnings      []string    `json:"warnings,omitempty"`
}

Snapshot is a point-in-time view of the daemon host's network interfaces. Warnings contain stable codes; raw platform errors stay in daemon logs.

func Collect

func Collect(ctx context.Context) (Snapshot, error)

Collect reads one host network snapshot. Partial data is returned together with an error when one platform source is unavailable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL