Documentation
¶
Overview ¶
Package rrd provides a client which can talk to rrdtool's rrdcached It supports all known commands and uses native golang types where appropriate.
Index ¶
- Constants
- Variables
- func IsExist(err error) bool
- func IsIllegalUpdate(err error) bool
- func IsNotExist(err error) bool
- func Mapping(name string, idx int) func(d *ds)
- func Timeout(timeout time.Duration) func(*Client) error
- func Unix(c *Client) error
- type Client
- func (c *Client) Batch(cmds ...*Cmd) error
- func (c *Client) Close() error
- func (c *Client) Create(filename string, ds []DS, rra []RRA, options ...CreateOption) error
- func (c *Client) Exec(cmd string) ([]string, error)
- func (c *Client) ExecCmd(cmd *Cmd) ([]string, error)
- func (c *Client) Fetch(filename, cf string, options ...interface{}) (*Fetch, error)
- func (c *Client) FetchBin(filename, cf string, options ...interface{}) (*FetchBin, error)
- func (c *Client) First(filename string, rra int) (time.Time, error)
- func (c *Client) Flush(filename string) error
- func (c *Client) FlushAll() error
- func (c *Client) Forget(filename string) error
- func (c *Client) Help(cmd ...string) ([]string, error)
- func (c *Client) Info(filename string) ([]*Info, error)
- func (c *Client) Last(filename string) (time.Time, error)
- func (c *Client) Pending(filename string) ([]string, error)
- func (c *Client) Ping() error
- func (c *Client) Queue(filename string) ([]*Queue, error)
- func (c *Client) Stats() (*Stats, error)
- func (c *Client) Update(filename string, value Update, values ...Update) error
- func (c *Client) Wrote(filename string) error
- type Cmd
- type CreateOption
- type DS
- func NewAbsolute(name string, heartbeat time.Duration, min, max int, options ...func(d *ds)) DS
- func NewCompute(name, cdef string, options ...func(d *ds)) DS
- func NewCounter(name string, heartbeat time.Duration, min, max int, options ...func(d *ds)) DS
- func NewDCounter(name string, heartbeat time.Duration, min, max int, options ...func(d *ds)) DS
- func NewDDerive(name string, heartbeat time.Duration, min, max int, options ...func(d *ds)) DS
- func NewDS(raw string) DS
- func NewDerive(name string, heartbeat time.Duration, min, max int, options ...func(d *ds)) DS
- func NewGauge(name string, heartbeat time.Duration, min, max int, options ...func(d *ds)) DS
- type Error
- type Fetch
- type FetchBin
- type FetchBinDS
- type FetchCommon
- type FetchRow
- type Info
- type InvalidResponseError
- type Queue
- type RRA
- func NewAverage(xff float32, steps, rows int) RRA
- func NewDevPredict(rows, idx int) RRA
- func NewDevSeasonal(period int, gamma float32, idx int, window float32) RRA
- func NewFailures(rows, threshold, window, idx int) RRA
- func NewHWPredict(rows int, alpha, beta float32, period int, idx int) RRA
- func NewLast(xff float32, steps, rows int) RRA
- func NewMHWPredict(rows int, alpha, beta float32, period int, idx int) RRA
- func NewMax(xff float32, steps, rows int) RRA
- func NewMin(xff float32, steps, rows int) RRA
- func NewRRA(val string) RRA
- func NewSeasonal(period int, gamma float32, idx int, window float32) RRA
- type Stats
- type Update
Constants ¶
const ( Gauge = "GAUGE" Counter = "COUNTER" DCounter = "DCOUNTER" Derive = "DERIVE" DDerive = "DDERIVE" Absolute = "ABSOLUTE" Compute = "COMPUTE" )
Data Source Types
const ( Average = "AVERAGE" Min = "MIN" Max = "MAX" Last = "LAST" HoltWintersPredict = "HWPREDICT" MultipliedHoltWinterPredict = "MHWPREDICT" Seasonal = "SEASONAL" DevSeasonal = "DEVSEASONAL" DevPredict = "DEVPREDICT" Failures = "FAILURES" )
Round Robin Algorithms
const (
// DefaultPort is the default rrdcached port.
DefaultPort = 42217
)
Variables ¶
var ( // DefaultTimeout is the default read / write / dial timeout for Clients. DefaultTimeout = time.Second * 10 )
var ( // ErrNilOption is returned by NewClient if an option is nil. ErrNilOption = errors.New("nil option") )
Functions ¶
func IsExist ¶
IsExist returns true if err represents a failure due to a existing rrd, false otherwise.
func IsIllegalUpdate ¶
IsIllegalUpdate returns true if err represents a failure due to an illegal update, false otherwise.
func IsNotExist ¶
IsNotExist returns true if err represents a failure due to a non-existing rrd, false otherwise.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a rrdcached client.
func NewClient ¶
NewClient returns a new rrdcached client connected to addr. By default addr is treated as a TCP address to use UNIX sockets pass Unix as an option. If addr for a TCP address doesn't include a port the DefaultPort will be used.
func (*Client) Fetch ¶
Fetch returns the free text results of a fetch command with the given options.
func (*Client) FetchBin ¶
FetchBin returns the text/binary results of a fetch command with the given options.
func (*Client) FlushAll ¶
FlushAll requests the rrdcached start to flush all pending values to disk.
func (*Client) Forget ¶
Forget requests rrdcached remove filename from the cache. Any pending updates WILL BE LOST.
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd represents a rrdcached command.
type CreateOption ¶
type CreateOption string
CreateOption represents a rrd create option.
func NoOverwrite ¶
func NoOverwrite() CreateOption
NoOverwrite returns a new create no overwrite option.
func Template ¶
func Template(file string) CreateOption
Template returns a new create template option.
type DS ¶
type DS string
DS represents a RRD data source.
func NewAbsolute ¶
NewAbsolute returns a new ABSOLUTE DS.
func NewCompute ¶
NewCompute returns a new COMPUTE DS.
func NewCounter ¶
NewCounter returns a new COUNTER DS.
func NewDCounter ¶
NewDCounter returns a new DCOUNTER DS.
func NewDDerive ¶
NewDDerive returns a new DDERIVE DS.
type Fetch ¶
type Fetch struct { FetchCommon Names []string Rows []FetchRow }
Fetch represents the data returned by an rrdcached fetch command.
type FetchBin ¶
type FetchBin struct { FetchCommon DS []*FetchBinDS }
FetchBin represents the response from a fetchbin command.
type FetchBinDS ¶
type FetchBinDS struct { Name string Records int Size int Endian binary.ByteOrder Data []interface{} }
FetchBinDS represents a row of binary data.
type FetchCommon ¶
type FetchCommon struct { FlushVersion int Start time.Time End time.Time Step time.Duration Count int }
FetchCommon represents the common fields between fetch and fetchbin
type Info ¶
type Info struct { Key string Value interface{} }
Info represents the configuration information of an RRD.
type InvalidResponseError ¶
InvalidResponseError is the error returned when the response data was invalid.
func NewInvalidResponseError ¶
func NewInvalidResponseError(reason string, lines ...string) *InvalidResponseError
NewInvalidResponseError returns a new InvalidResponseError from lines.
func (*InvalidResponseError) Error ¶
func (e *InvalidResponseError) Error() string
type RRA ¶
type RRA string
RRA represents a raw RRA.
func NewAverage ¶
NewAverage returns a new AVERAGE RRA.
func NewDevPredict ¶
NewDevPredict returns a new HWPREDICT RRA.
func NewDevSeasonal ¶
NewDevSeasonal returns a new HWPREDICT RRA.
func NewFailures ¶
NewFailures returns a new HWPREDICT RRA.
func NewHWPredict ¶
NewHWPredict returns a new HWPREDICT RRA.
func NewMHWPredict ¶
NewMHWPredict returns a new HWPREDICT RRA.
type Stats ¶
type Stats struct { QueueLength int64 UpdatesReceived int64 FlushesReceived int64 UpdatesWritten int64 DataSetsWritten int64 TreeNodesNumber int64 TreeDepth int64 JournalBytes int64 JournalRotate int64 }
Stats represents rrdcached stats.
type Update ¶
type Update string
Update represents a RRD update value.
func NewUpdateNow ¶
func NewUpdateNow(val interface{}, values ...interface{}) Update
NewUpdateNow returns a new update with the current time for the provided values.
func NewUpdateRaw ¶
NewUpdateRaw returns a new Update for the raw val. It supports the N: prefix for now times.