Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InterfaceStatus ¶
type InterfaceStatus int
InterfaceStatus represents the link status of an interface.
const ( // InterfaceUnknown represents an interface with no assigned state. InterfaceUnknown InterfaceStatus = iota // InterfaceUp represents an interface with a cable connected. InterfaceUp // InterfaceDown represents an interface with no cable connected. InterfaceDown // InterfaceErr represents an interface with errors querying its status. InterfaceErr )
func GetLinkStatus ¶
func GetLinkStatus(iface string) (InterfaceStatus, error)
GetLinkStatus returns, for a given interface, the corresponding status code at the time of the call. If any error was encountered (e.g. invalid interface, etc.) we simply return ifplugo.InterfaceErr.
func (InterfaceStatus) String ¶
func (s InterfaceStatus) String() string
type LinkStatusMonitor ¶
type LinkStatusMonitor struct { PollPeriod time.Duration LastStatus map[string]InterfaceStatus LastStats map[string]net.IOCountersStat OutChan chan LinkStatusSample CloseChan chan bool ClosedChan chan bool Ifaces []string // contains filtered or unexported fields }
LinkStatusMonitor represents a concurrent software component that periodically checks a list of given interfaces and returns their link status via a specified channel.
func MakeLinkStatusMonitor ¶
func MakeLinkStatusMonitor(pollPeriod time.Duration, ifaces []string, outChan chan LinkStatusSample) *LinkStatusMonitor
MakeLinkStatusMonitor creates a new LinkStatusMonitor, polling each interval given in pollPeriod for the status information of the interfaces given in ifaces and outputting results as a map of interface->status pairs in the channel outChan.
func (*LinkStatusMonitor) CheckIncomingDelta ¶
func (a *LinkStatusMonitor) CheckIncomingDelta(val bool, threshold uint64)
CheckIncomingDelta allows to enable the optional behaviour to also consider an interface as 'up' if traffic is received on it. This is, for example, necessary in passive monitoring setups where there is no physical link detected (e.g. using taps that only provide RX lines).
func (*LinkStatusMonitor) Run ¶
func (a *LinkStatusMonitor) Run()
Run starts watching interfaces in the background.
func (*LinkStatusMonitor) Stop ¶
func (a *LinkStatusMonitor) Stop()
Stop causes the monitor to cease monitoring interfaces.
type LinkStatusSample ¶
type LinkStatusSample struct {
Ifaces map[string]InterfaceStatus
}
LinkStatusSample is a single description of the link status at a given time. Changed is set to true if the state is different than the previously emitted one.