import "github.com/fadhilyori/subping"- func RunPing(ipAddress string, count int, interval time.Duration, timeout time.Duration) ping.Statistics
- type Options
- type Subping
func RunPing(ipAddress string, count int, interval time.Duration, timeout time.Duration) ping.StatisticsRunPing sends ICMP echo requests to the specified IP address and returns the ping statistics.
Options holds the configuration options for creating a new Subping instance.
type Options struct {
// List of IP addresses to ping
Targets []net.IP
// Number of ping packets to send
Count int
// Interval for each ping request
Interval time.Duration
// Timeout specifies a timeout before exits each target
Timeout time.Duration
// Number of concurrent jobs to execute
NumJobs int
}Subping is a utility for concurrently pinging multiple IP addresses and collecting the Results.
type Subping struct {
// List of IP addresses to ping
Targets []net.IP
// Number of ping packets to send
Count int
// Interval for each ping request
Interval time.Duration
// Timeout specifies a timeout before exits each target
Timeout time.Duration
// Number of concurrent jobs to execute
NumJobs int
// Results of the ping requests
Results map[string]ping.Statistics
// PartitionedTargets List of IP addresses that have already been partitioned for pinging.
PartitionedTargets [][]net.IP
}func NewSubping(opts *Options) (Subping, error)NewSubping creates a new Subping instance with the provided options.
func (s *Subping) GetOnlineHosts() map[string]ping.StatisticsGetOnlineHosts returns the Results of the ping requests for IP addresses that responded successfully.
func (s *Subping) Run()Run starts the ping operation on the specified IP addresses using the configured options.
Generated by gomarkdoc