Documentation
¶
Index ¶
- Constants
- Variables
- type CounterSample
- type Datagram
- type Decoder
- type Encoder
- type EthernetCounters
- type EventDiscardedPacket
- type ExtendedSwitchFlow
- type FlowSample
- type GenericInterfaceCounters
- type HostCPUCounters
- type HostDiskCounters
- type HostMemoryCounters
- type HostNetCounters
- type ProcessorCounters
- type RawPacketFlow
- type Record
- type Sample
- type TokenRingCounters
- type VgCounters
- type VlanCounters
Constants ¶
const ( TypeGenericInterfaceCountersRecord = 1 TypeEthernetCountersRecord = 2 TypeTokenRingCountersRecord = 3 TypeVgCountersRecord = 4 TypeVlanCountersRecord = 5 TypeProcessorCountersRecord = 1001 TypeHostCPUCountersRecord = 2003 TypeHostMemoryCountersRecord = 2004 TypeHostDiskCountersRecord = 2005 TypeHostNetCountersRecord = 2006 // Custom (Enterprise) types TypeApplicationCountersRecord = (1)<<12 + 1 )
const ( // MaximumRecordLength defines the maximum length acceptable for decoded records. // This maximum prevents from excessive memory allocation. // The value is derived from MAX_PKT_SIZ 65536 in the reference sFlow implementation // https://github.com/sflow/sflowtool/blob/bd3df6e11bdf/src/sflowtool.c#L4313. MaximumRecordLength = 65536 // MaximumHeaderLength defines the maximum length acceptable for decoded flow samples. // This maximum prevents from excessive memory allocation. // The value is set to maximum transmission unit (MTU), as the header of a network packet // may not exceed the MTU. MaximumHeaderLength = 1500 )
const ( TypeRawPacketFlowRecord = 1 TypeEthernetFrameFlowRecord = 2 TypeIpv4FlowRecord = 3 TypeIpv6FlowRecord = 4 TypeExtendedSwitchFlowRecord = 1001 TypeExtendedRouterFlowRecord = 1002 TypeExtendedGatewayFlowRecord = 1003 TypeExtendedUserFlowRecord = 1004 TypeExtendedUrlFlowRecord = 1005 TypeExtendedMlpsFlowRecord = 1006 TypeExtendedNatFlowRecord = 1007 TypeExtendedMlpsTunnelFlowRecord = 1008 TypeExtendedMlpsVcFlowRecord = 1009 TypeExtendedMlpsFecFlowRecord = 1010 TypeExtendedMlpsLvpFecFlowRecord = 1011 TypeExtendedVlanFlowRecord = 1012 )
const ( TypeFlowSample = 1 TypeCounterSample = 2 TypeExpandedFlowSample = 3 TypeExpandedCounterSample = 4 TypeEventDiscardedPacket = 5 )
Variables ¶
var ( ErrInvalidSliceLength = errors.New("sflow: invalid slice length") ErrInvalidFieldType = errors.New("sflow: field type") )
var ( ErrEncodingRecord = errors.New("sflow: failed to encode record") ErrDecodingRecord = errors.New("sflow: failed to decode record") )
var (
ErrNoSamplesProvided = errors.New("sflow: no samples provided for encoding")
)
var (
ErrUnknownSampleType = errors.New("sflow: Unknown sample type")
)
var ErrUnsupportedDatagramVersion = errors.New("sflow: unsupported datagram version")
Functions ¶
This section is empty.
Types ¶
type CounterSample ¶
type CounterSample struct {
SequenceNum uint32
SourceIdType byte
SourceIdIndexVal uint32 // NOTE: this is 3 bytes in the datagram
Records []Record
// contains filtered or unexported fields
}
func (*CounterSample) GetRecords ¶
func (s *CounterSample) GetRecords() []Record
func (*CounterSample) SampleType ¶
func (s *CounterSample) SampleType() int
SampleType returns the type of sFlow sample.
func (CounterSample) String ¶
func (s CounterSample) String() string
type Datagram ¶
type Datagram struct {
Version uint32 `json:"version"`
IpVersion uint32 `json:"ipVersion"`
IpAddress net.IP `json:"ipAddress"`
SubAgentId uint32 `json:"subAgentId"`
SequenceNumber uint32 `json:"sequenceNumber"`
Uptime uint32 `json:"uptime"`
NumSamples uint32 `json:"numSamples"`
Samples []Sample `json:"samples"`
}
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoder(r io.ReadSeeker) *Decoder
func (*Decoder) Use ¶
func (d *Decoder) Use(r io.ReadSeeker)
type Encoder ¶
type Encoder struct {
Uptime uint32
// contains filtered or unexported fields
}
func NewEncoder ¶
NewEncoder returns a new sFlow encoder.
type EthernetCounters ¶
type EthernetCounters struct {
AlignmentErrors uint32
FCSErrors uint32
SingleCollisionFrames uint32
MultipleCollisionFrames uint32
SQETestErrors uint32
DeferredTransmissions uint32
LateCollisions uint32
ExcessiveCollisions uint32
InternalMACTransmitErrors uint32
CarrierSenseErrors uint32
FrameTooLongs uint32
InternalMACReceiveErrors uint32
SymbolErrors uint32
}
EthernetCounters is an Ethernet interface counters record.
func (EthernetCounters) RecordType ¶
func (c EthernetCounters) RecordType() int
RecordType returns the type of counter record.
func (EthernetCounters) String ¶
func (c EthernetCounters) String() string
type EventDiscardedPacket ¶
type EventDiscardedPacket struct {
SequenceNum uint32
DsClass uint32
DsIndex uint32
Drops uint32
Input uint32
Output uint32
Reason uint32
Records []Record
// contains filtered or unexported fields
}
func (*EventDiscardedPacket) GetRecords ¶
func (s *EventDiscardedPacket) GetRecords() []Record
func (*EventDiscardedPacket) SampleType ¶
func (s *EventDiscardedPacket) SampleType() int
SampleType returns the type of sFlow sample.
func (EventDiscardedPacket) String ¶
func (s EventDiscardedPacket) String() string
type ExtendedSwitchFlow ¶
type ExtendedSwitchFlow struct {
SourceVlan uint32
SourcePriority uint32
DestinationVlan uint32
DestinationPriority uint32
}
ExtendedSwitchFlow is an extended switch flow record.
func (ExtendedSwitchFlow) RecordType ¶
func (f ExtendedSwitchFlow) RecordType() int
RecordType returns the type of flow record.
func (ExtendedSwitchFlow) String ¶
func (f ExtendedSwitchFlow) String() string
type FlowSample ¶
type FlowSample struct {
SequenceNum uint32
SourceIdType byte
SourceIdIndexVal uint32 // NOTE: this is 3 bytes in the datagram
SamplingRate uint32
SamplePool uint32
Drops uint32
Input uint32
Output uint32
Records []Record
// contains filtered or unexported fields
}
func (*FlowSample) GetRecords ¶
func (s *FlowSample) GetRecords() []Record
func (*FlowSample) SampleType ¶
func (s *FlowSample) SampleType() int
SampleType returns the type of sFlow sample.
func (FlowSample) String ¶
func (s FlowSample) String() string
type GenericInterfaceCounters ¶
type GenericInterfaceCounters struct {
Index uint32
Type uint32
Speed uint64
Direction uint32
Status uint32
InOctets uint64
InUnicastPackets uint32
InMulticastPackets uint32
InBroadcastPackets uint32
InDiscards uint32
InErrors uint32
InUnknownProtocols uint32
OutOctets uint64
OutUnicastPackets uint32
OutMulticastPackets uint32
OutBroadcastPackets uint32
OutDiscards uint32
OutErrors uint32
PromiscuousMode uint32
}
GenericInterfaceCounters is a generic switch counters record.
func (GenericInterfaceCounters) RecordType ¶
func (c GenericInterfaceCounters) RecordType() int
RecordType returns the type of counter record.
func (GenericInterfaceCounters) String ¶
func (c GenericInterfaceCounters) String() string
type HostCPUCounters ¶
type HostCPUCounters struct {
Load1m float32
Load5m float32
Load15m float32
ProcessesRunning uint32
ProcessesTotal uint32
NumCPU uint32
SpeedCPU uint32
Uptime uint32
CPUUser uint32
CPUNice uint32
CPUSys uint32
CPUIdle uint32
CPUWio uint32
CPUIntr uint32
CPUSoftIntr uint32
Interrupts uint32
ContextSwitches uint32
CPUSteal uint32
CPUGuest uint32
CPUGuestNice uint32
}
HostCPUCounters is a host CPU counters record.
func (HostCPUCounters) RecordType ¶
func (c HostCPUCounters) RecordType() int
RecordType returns the type of counter record.
func (HostCPUCounters) String ¶
func (c HostCPUCounters) String() string
type HostDiskCounters ¶
type HostDiskCounters struct {
Total uint64
Free uint64
MaxUsedPercent float32
Reads uint32
BytesRead uint64
ReadTime uint32
Writes uint32
BytesWritten uint64
WriteTime uint32
}
HostDiskCounters is a host disk counters record.
func (HostDiskCounters) RecordType ¶
func (c HostDiskCounters) RecordType() int
RecordType returns the type of counter record.
func (HostDiskCounters) String ¶
func (c HostDiskCounters) String() string
type HostMemoryCounters ¶
type HostMemoryCounters struct {
Total uint64
Free uint64
Buffers uint64
Cached uint64
SwapTotal uint64
SwapFree uint64
PageIn uint32
PageOut uint32
SwapIn uint32
SwapOut uint32
}
HostMemoryCounters is a host memory counters record.
func (HostMemoryCounters) RecordType ¶
func (c HostMemoryCounters) RecordType() int
RecordType returns the type of counter record.
func (HostMemoryCounters) String ¶
func (c HostMemoryCounters) String() string
type HostNetCounters ¶
type HostNetCounters struct {
BytesIn uint64
PacketsIn uint32
ErrorsIn uint32
DropsIn uint32
BytesOut uint64
PacketsOut uint32
ErrorsOut uint32
DropsOut uint32
}
HostNetCounters is a host network counters record.
func (HostNetCounters) RecordType ¶
func (c HostNetCounters) RecordType() int
RecordType returns the type of counter record.
func (HostNetCounters) String ¶
func (c HostNetCounters) String() string
type ProcessorCounters ¶
type ProcessorCounters struct {
CPU5s uint32
CPU1m uint32
CPU5m uint32
TotalMemory uint64
FreeMemory uint64
}
ProcessorCounters is a switch processor counters record.
func (ProcessorCounters) RecordType ¶
func (c ProcessorCounters) RecordType() int
RecordType returns the type of counter record.
func (ProcessorCounters) String ¶
func (c ProcessorCounters) String() string
type RawPacketFlow ¶
type RawPacketFlow struct {
Protocol uint32
FrameLength uint32
Stripped uint32
HeaderSize uint32
Header []byte
}
RawPacketFlow is a raw Ethernet header flow record.
func (RawPacketFlow) RecordType ¶
func (f RawPacketFlow) RecordType() int
RecordType returns the type of flow record.
func (RawPacketFlow) String ¶
func (f RawPacketFlow) String() string
type TokenRingCounters ¶
type TokenRingCounters struct {
LineErrors uint32
BurstErrors uint32
ACErrors uint32
AbortTransErrors uint32
InternalErrors uint32
LostFrameErrors uint32
ReceiveCongestions uint32
FrameCopiedErrors uint32
TokenErrors uint32
SoftErrors uint32
HardErrors uint32
SignalLoss uint32
TransmitBeacons uint32
Recoverys uint32
LobeWires uint32
Removes uint32
Singles uint32
FreqErrors uint32
}
TokenRingCounters is a token ring interface counters record.
func (TokenRingCounters) RecordType ¶
func (c TokenRingCounters) RecordType() int
RecordType returns the type of counter record.
func (TokenRingCounters) String ¶
func (c TokenRingCounters) String() string
type VgCounters ¶
type VgCounters struct {
InHighPriorityFrames uint32
InHighPriorityOctets uint64
InNormPriorityFrames uint32
InNormPriorityOctets uint64
InIPMErrors uint32
InOversizeFrameErrors uint32
InDataErrors uint32
InNullAddressedFrames uint32
OutHighPriorityFrames uint32
OutHighPriorityOctets uint64
TransitionIntoTrainings uint32
HCInHighPriorityOctets uint64
HCInNormPriorityOctets uint64
HCOutHighPriorityOctets uint64
}
VgCounters is a BaseVG interface counters record.
func (VgCounters) RecordType ¶
func (c VgCounters) RecordType() int
RecordType returns the type of counter record.
func (VgCounters) String ¶
func (c VgCounters) String() string
type VlanCounters ¶
type VlanCounters struct {
ID uint32
Octets uint64
UnicastPackets uint32
MulticastPackets uint32
BroadcastPackets uint32
Discards uint32
}
VlanCounters is a VLAN counters record.
func (VlanCounters) RecordType ¶
func (c VlanCounters) RecordType() int
RecordType returns the type of counter record.
func (VlanCounters) String ¶
func (c VlanCounters) String() string