Documentation
¶
Overview ¶
gocollectd parses the collectd binary protocol.
Index ¶
- Constants
- Variables
- func Listen(addr string, c chan Packet)
- func Parse(b []byte) (*[]Packet, error)
- type Absolute
- type Counter
- type Derive
- type Gauge
- type Number
- type Packet
- func (p Packet) Name() (name string)
- func (p Packet) Time() time.Time
- func (p Packet) TimeUnix() int64
- func (p Packet) TimeUnixNano() int64
- func (p Packet) ValueBytes() [][]byte
- func (p Packet) ValueCount() int
- func (p Packet) ValueNames() []string
- func (p Packet) ValueNumbers() ([]Number, error)
- func (p Packet) Values() []Value
- type Value
Constants ¶
const ( TypeCounter = 0 TypeGauge = 1 TypeDerive = 2 TypeAbsolute = 3 )
Variables ¶
var ErrorInvalid = errors.New("Invalid collectd packet recieved")
The error returned if an invalid packet is recieved
var ErrorUnsupported = errors.New("Unsupported collectd packet recieved")
The error returned if a valid but unsupported packet is recieved
Functions ¶
Types ¶
type Absolute ¶
type Absolute uint64
A collectd Absolute value
func (Absolute) CollectdType ¶
CollectdType returns TypeAbsolute
type Counter ¶
type Counter uint64
A collectd Counter value
func (Counter) CollectdType ¶
CollectdType returns TypeCounter
type Number ¶
type Number interface {
// CollectdType gives the Collectd Type of this number.
CollectdType() uint8
// Float64 converts this number to a float to avoid type assertions.
Float64() float64
}
A collectd value is sent as a int64, uint64, or float64. Number provides some useful functions to help handle this flexibility.
type Packet ¶
type Packet struct {
Hostname string
Plugin string
PluginInstance string
Type string
TypeInstance string
CdTime uint64
CdInterval uint64
DataTypes []uint8
Bytes []byte
}
A packet is a set of collectd values that were sent at once by a collectd plugin.
func (Packet) Name ¶
ValueNames attempts to reformat collectd's plugin/type/instance heirarchy into a string for this packet.
func (Packet) TimeUnixNano ¶
TimeUnixNano returns the measurement time in nanoseconds since unix epoch.
func (Packet) ValueBytes ¶
ValueBytes returns the raw bytes for each value.
func (Packet) ValueCount ¶
ValueCount returns the number of values in this packet.
func (Packet) ValueNames ¶
ValueNames attempts to reformat collectd's plugin/type/instance heirarchy into a strings for each value in this packet.
func (Packet) ValueNumbers ¶
ValueNumbers returns the values as Numbers