Documentation ¶
Index ¶
- Constants
- Variables
- func CheckProbeCapabilities(probeType string, capability ProbeCapability) bool
- func CrossTypeCompare(a interface{}, b interface{}) (int, error)
- func CrossTypeEqual(a interface{}, b interface{}) bool
- func DelField(obj map[string]interface{}, k string) bool
- func GetField(obj map[string]interface{}, k string) (interface{}, error)
- func GetFieldKeys(obj map[string]interface{}) []string
- func IPV4CIDRToRegex(cidr string) (string, error)
- func IPv6Supported() bool
- func IsCaptureAllowed(nodeType string) bool
- func IsIPv6(str string) bool
- func JSONDecode(r io.Reader, i interface{}) error
- func LookupPath(obj interface{}, path string, kind reflect.Kind) (reflect.Value, bool)
- func MaxInt64(a, b int64) int64
- func MinInt64(a, b int64) int64
- func NormalizeAddrForURL(addr string) string
- func NormalizeIPForURL(ip net.IP) string
- func NormalizeValue(obj interface{}) interface{}
- func ParseAddr(address string) (protocol string, target string, err error)
- func ProbeTypeForNode(nodeType string, captureType string) (string, error)
- func RandString(n int) string
- func RangeToRegex(min, max int) string
- func Retry(fnc func() error, try int, delay time.Duration) error
- func RetryExponential(fnc func() error, try int, baseDelay time.Duration) error
- func SetField(obj map[string]interface{}, k string, v interface{}) bool
- func SetupTLSClientConfig(certPEM string, keyPEM string) (*tls.Config, error)
- func SetupTLSLoadCA(certPEM string) (*x509.CertPool, error)
- func SetupTLSServerConfig(certPEM string, keyPEM string) (*tls.Config, error)
- func StructFieldKeys(i interface{}) []string
- func ToFloat64(f interface{}) (float64, error)
- func ToInt64(i interface{}) (int64, error)
- func UnixMillis(t time.Time) int64
- type CaptureType
- type Debouncer
- type Getter
- type Iterator
- type MasterElection
- type MasterElectionListener
- type MasterElectionService
- type Metric
- type NetNSContext
- type PortAllocator
- type ProbeCapability
- type ProcessInfo
- type ProcessState
- type RWMutex
- type RawSocket
- type Service
- type ServiceAddress
- type ServiceType
- type SortOrder
- type TimeSlice
Constants ¶
const ( // BPFCapability the probe is able to handle bpf filters BPFCapability ProbeCapability = 1 // RawPacketsCapability the probe can capture raw packets RawPacketsCapability = 2 // ExtraTCPMetricCapability the probe can report TCP metrics ExtraTCPMetricCapability = 4 )
const ( AllPackets = syscall.ETH_P_ALL OnlyIPPackets = syscall.ETH_P_IP )
Protocols to receive
const ( // StoppedState service stopped StoppedState = iota + 1 // RunningState service running RunningState // StoppingState service stopping StoppingState )
Variables ¶
var ( // ProbeTypes returns a list of all the capture probes ProbeTypes = []string{"ovssflow", "pcapsocket", "ovsmirror", "dpdk", "afpacket", "pcap", "ebpf", "sflow"} // CaptureTypes contains all registered capture type and associated probes CaptureTypes = map[string]CaptureType{} // ProbeCapabilities defines capability per probes ProbeCapabilities = map[string]ProbeCapability{} )
var ( // ErrInvalidPortRange invalid port range ErrInvalidPortRange = errors.New("Invalid port range") // ErrNoPortLeft no port left in the range ErrNoPortLeft = errors.New("No free port left") )
var ( // ErrCantCompareInterface error can't compare interface ErrCantCompareInterface = errors.New("Can't compare interface") // ErrFieldNotFound error field not found ErrFieldNotFound = errors.New("Field not found") // ErrFieldWrongType error field has wrong type ErrFieldWrongType = errors.New("Field has wrong type") // ErrNotFound error no result was found ErrNotFound = errors.New("No result found") // ErrTimeout network timeout ErrTimeout = errors.New("Timeout") // ErrNotImplemented unimplemented feature ErrNotImplemented = errors.New("Not implemented") )
Functions ¶
func CheckProbeCapabilities ¶ added in v0.15.0
func CheckProbeCapabilities(probeType string, capability ProbeCapability) bool
CheckProbeCapabilities checks that a probe supports given capabilities
func CrossTypeCompare ¶ added in v0.5.0
CrossTypeCompare compare 2 differents number types like Float64 vs Float32
func CrossTypeEqual ¶
func CrossTypeEqual(a interface{}, b interface{}) bool
CrossTypeEqual compare 2 differents number types
func GetField ¶ added in v0.12.0
GetField retrieves a value from a tree from the dot key like "a.b.c.d"
func GetFieldKeys ¶ added in v0.21.0
GetFieldKeys returns all the keys using dot notation
func IPV4CIDRToRegex ¶ added in v0.13.0
IPV4CIDRToRegex returns a regex matching IPs belonging to a given cidr
func IPv6Supported ¶ added in v0.8.0
func IPv6Supported() bool
IPv6Supported returns true if the platform support IPv6
func IsCaptureAllowed ¶ added in v0.5.0
IsCaptureAllowed returns true if the node capture type exist
func JSONDecode ¶ added in v0.12.0
JSONDecode wrapper to UseNumber during JSON decoding
func LookupPath ¶ added in v0.21.0
LookupPath lookup through the given obj according to the given path return the value found if the kind matches
func NormalizeAddrForURL ¶ added in v0.15.0
NormalizeAddrForURL format the given address to be used in URL. For IPV6 addresses the brackets will be added.
func NormalizeIPForURL ¶ added in v0.19.0
NormalizeIPForURL returns a string normalized that can be used in URL. Brackets will be used for IPV6 addresses.
func NormalizeValue ¶ added in v0.14.0
func NormalizeValue(obj interface{}) interface{}
NormalizeValue returns a version of the passed value that can be safely marshalled to JSON
func ParseAddr ¶ added in v0.23.0
ParseAddr parses an address of the form protocol://target such as unix:////var/run/service/program.sock or tcp://my.domain:2134. It also handles addresses of the form address:port and assumes it uses TCP.
func ProbeTypeForNode ¶ added in v0.16.0
ProbeTypeForNode returns the appropriate probe type for the given node type and capture type.
func RangeToRegex ¶ added in v0.13.0
RangeToRegex returns a regular expression matching number in the given range Golang version of https://github.com/dimka665/range-regex
func Retry ¶
Retry tries to execute the given function until a success applying a delay between each try
func RetryExponential ¶ added in v0.18.0
RetryExponential tries to execute the given function until a success applying a delay between each try. The delay is doubled after each try. Its initial value is baseDelay.
func SetupTLSClientConfig ¶ added in v0.12.0
SetupTLSClientConfig creates a client X509 certificate from public and private key
func SetupTLSLoadCA ¶ added in v0.21.0
SetupTLSLoadCA creates an X509 certificate from file
func SetupTLSServerConfig ¶ added in v0.12.0
SetupTLSServerConfig creates a server X509 certificate from public and private key
func StructFieldKeys ¶ added in v0.19.0
func StructFieldKeys(i interface{}) []string
StructFieldKeys returns field names of a structure
func UnixMillis ¶ added in v0.10.0
UnixMillis returns the current time in miliseconds
Types ¶
type CaptureType ¶ added in v0.7.0
CaptureType describes a list of allowed and default captures probes
type Debouncer ¶ added in v0.16.0
type Debouncer struct {
// contains filtered or unexported fields
}
Debouncer defines a debouncer object
func NewDebouncer ¶ added in v0.16.0
NewDebouncer returns a Debouncer calling the given callback after a certain amount of time.
type Getter ¶ added in v0.21.0
type Getter interface { GetField(field string) (interface{}, error) GetFieldKeys() []string GetFieldInt64(field string) (int64, error) GetFieldString(field string) (string, error) }
Getter describes filter getter fields
type Iterator ¶ added in v0.6.0
type Iterator struct {
// contains filtered or unexported fields
}
Iterator describes a int64 iterator
func NewIterator ¶ added in v0.6.0
NewIterator creates a new iterator based on (at, from, to) parameters
type MasterElection ¶ added in v0.22.0
type MasterElection interface { Start() StartAndWait() Stop() IsMaster() bool AddEventListener(listener MasterElectionListener) TTL() time.Duration }
MasterElection describes the master election mechanism
type MasterElectionListener ¶ added in v0.22.0
type MasterElectionListener interface { OnStartAsMaster() OnStartAsSlave() OnSwitchToMaster() OnSwitchToSlave() }
MasterElectionListener describes the multi election mechanism
type MasterElectionService ¶ added in v0.22.0
type MasterElectionService interface {
NewElection(key string) MasterElection
}
MasterElectionService describes the election service mechanism
type Metric ¶ added in v0.10.0
type Metric interface { // part of the Getter interface GetFieldInt64(field string) (int64, error) GetFieldKeys() []string Add(m Metric) Metric Sub(m Metric) Metric Split(cut int64) (Metric, Metric) GetStart() int64 SetStart(start int64) GetLast() int64 SetLast(last int64) IsZero() bool }
Metric defines a common metric interface
type NetNSContext ¶ added in v0.8.0
type NetNSContext struct {
// contains filtered or unexported fields
}
NetNSContext describes a NameSpace Context switch API
func NewNetNsContext ¶ added in v0.8.0
func NewNetNsContext(path string) (*NetNSContext, error)
NewNetNsContext creates a new NameSpace context base on path
func (*NetNSContext) Quit ¶ added in v0.8.0
func (n *NetNSContext) Quit() error
Quit the NameSpace and go back to the original one
type PortAllocator ¶ added in v0.10.0
PortAllocator describes a threads safe port list that can be allocated
func NewPortAllocator ¶ added in v0.10.0
func NewPortAllocator(min, max int) (*PortAllocator, error)
NewPortAllocator creates a new port allocator range
func (*PortAllocator) Allocate ¶ added in v0.10.0
func (p *PortAllocator) Allocate() (int, error)
Allocate returns a new port between min and max ports.
func (*PortAllocator) Release ¶ added in v0.10.0
func (p *PortAllocator) Release(i int) error
Release a port
func (*PortAllocator) ReleaseAll ¶ added in v0.10.0
func (p *PortAllocator) ReleaseAll()
ReleaseAll ports
type ProbeCapability ¶ added in v0.15.0
type ProbeCapability int
ProbeCapability defines probe capability
type ProcessInfo ¶ added in v0.21.0
type ProcessInfo struct { Process string Pid int64 Name string PPid int64 PGrp int64 Session int64 Utime int64 Stime int64 CUtime int64 CStime int64 Priority int64 Nice int64 Threads int64 Start int64 Vsize int64 RSS int64 State ProcessState }
ProcessInfo describes the information of a running process
func GetProcessInfo ¶ added in v0.21.0
func GetProcessInfo(pid int) (*ProcessInfo, error)
GetProcessInfo retrieve process info from /proc
type ProcessState ¶ added in v0.21.0
type ProcessState rune
ProcessState describes the state of a process
const ( // Running state Running ProcessState = 'R' // Sleeping state Sleeping ProcessState = 'S' // Waiting state Waiting ProcessState = 'D' // Zombie state Zombie ProcessState = 'Z' // Stopped state Stopped ProcessState = 'T' // TracingStop state TracingStop ProcessState = 't' // Dead state Dead ProcessState = 'X' )
type RawSocket ¶ added in v0.12.0
type RawSocket struct {
// contains filtered or unexported fields
}
RawSocket describes a raw socket C implemenation
func NewRawSocket ¶ added in v0.12.0
NewRawSocket creates a raw socket for the network interface ifName
func NewRawSocketInNs ¶ added in v0.12.0
NewRawSocketInNs create/open a socket in the namespace nsPath for the network interface ifName
type Service ¶ added in v0.22.0
type Service struct { Type ServiceType ID string }
Service describes a service identified by its type and identifier
type ServiceAddress ¶ added in v0.10.0
ServiceAddress describes the service listening address and port
func ServiceAddressFromString ¶ added in v0.10.0
func ServiceAddressFromString(addressPort string) (ServiceAddress, error)
ServiceAddressFromString returns a service address from a string, could be IPv4 or IPv6
func (ServiceAddress) String ¶ added in v0.14.0
func (sa ServiceAddress) String() string
type ServiceType ¶ added in v0.10.0
type ServiceType string
ServiceType describes the service type (analyzer or agent)
const ( // UnknownService for unknown client types UnknownService ServiceType = "unknown" // AnalyzerService analyzer AnalyzerService ServiceType = "analyzer" // AgentService agent AgentService ServiceType = "agent" )
func (ServiceType) String ¶ added in v0.10.0
func (st ServiceType) String() string