rrd: github.com/ziutek/rrd Index | Examples | Files

package rrd

import "github.com/ziutek/rrd"

Simple wrapper for rrdtool C library

Index

Examples

Package Files

rrd.go rrd_c.go

func Info Uses

func Info(filename string) (map[string]interface{}, error)

Info returns information about RRD file.

type Creator Uses

type Creator struct {
    // contains filtered or unexported fields
}

func NewCreator Uses

func NewCreator(filename string, start time.Time, step uint) *Creator

NewCreator returns new Creator object. You need to call Create to really create database file.

filename - name of database file
start    - don't accept any data timed before or at time specified
step     - base interval in seconds with which data will be fed into RRD

func (*Creator) Create Uses

func (c *Creator) Create(overwrite bool) error

Create creates new database file. If overwrite is true it overwrites database file if exists. If overwrite is false it returns error if file exists (you can use os.IsExist function to check this case).

func (*Creator) DS Uses

func (c *Creator) DS(name, compute string, args ...interface{})

DS formats a DS argument and appends it to the list of arguments to be passed to rrdcreate(). Each element of args is formatted with fmt.Sprint(). Please see the rrdcreate(1) manual page for in-depth documentation.

Code:

c := &Creator{}

// Add a normal data source, i.e. one of GAUGE, COUNTER, DERIVE and ABSOLUTE:
c.DS("regular_ds", "DERIVE",
    900, /* heartbeat */
    0,   /* min */
    "U" /* max */)

// Add a computed
c.DS("computed_ds", "COMPUTE",
    "regular_ds,8,*" /* RPN expression */)

func (*Creator) RRA Uses

func (c *Creator) RRA(cf string, args ...interface{})

RRA formats an RRA argument and appends it to the list of arguments to be passed to rrdcreate(). Each element of args is formatted with fmt.Sprint(). Please see the rrdcreate(1) manual page for in-depth documentation.

Code:

c := &Creator{}

// Add a normal consolidation function, i.e. one of MIN, MAX, AVERAGE and LAST:
c.RRA("AVERAGE",
    0.3, /* xff */
    5,   /* steps */
    1200 /* rows */)

// Add aberrant behavior detection:
c.RRA("HWPREDICT",
    1200, /* rows */
    0.4,  /* alpha */
    0.5,  /* beta */
    288 /* seasonal period */)

type Error Uses

type Error string

func (Error) Error Uses

func (e Error) Error() string

type Exporter Uses

type Exporter struct {
    // contains filtered or unexported fields
}

func NewExporter Uses

func NewExporter() *Exporter

func (*Exporter) CDef Uses

func (e *Exporter) CDef(vname, rpn string)

func (*Exporter) Def Uses

func (e *Exporter) Def(vname, rrdfile, dsname, cf string, options ...string)

func (*Exporter) SetDaemon Uses

func (e *Exporter) SetDaemon(daemon string)

func (*Exporter) SetMaxRows Uses

func (e *Exporter) SetMaxRows(maxRows uint)

func (*Exporter) Xport Uses

func (e *Exporter) Xport(start, end time.Time, step time.Duration) (XportResult, error)

func (*Exporter) XportDef Uses

func (e *Exporter) XportDef(vname, label string)

type FetchResult Uses

type FetchResult struct {
    Filename string
    Cf       string
    Start    time.Time
    End      time.Time
    Step     time.Duration
    DsNames  []string
    RowCnt   int
    // contains filtered or unexported fields
}

func Fetch Uses

func Fetch(filename, cf string, start, end time.Time, step time.Duration) (FetchResult, error)

Fetch retrieves data from RRD file.

func (*FetchResult) FreeValues Uses

func (r *FetchResult) FreeValues()

FreeValues free values memory allocated by C.

func (*FetchResult) ValueAt Uses

func (r *FetchResult) ValueAt(dsIndex, rowIndex int) float64

func (*FetchResult) Values Uses

func (r *FetchResult) Values() []float64

Values returns copy of internal array of values.

type GraphInfo Uses

type GraphInfo struct {
    Print         []string
    Width, Height uint
    Ymin, Ymax    float64
}

type Grapher Uses

type Grapher struct {
    // contains filtered or unexported fields
}

func NewGrapher Uses

func NewGrapher() *Grapher

func (*Grapher) AddOptions Uses

func (g *Grapher) AddOptions(options ...string)

func (*Grapher) Area Uses

func (g *Grapher) Area(value, color string, options ...string)

func (*Grapher) CDef Uses

func (g *Grapher) CDef(vname, rpn string)

func (*Grapher) Comment Uses

func (g *Grapher) Comment(s string)

func (*Grapher) Def Uses

func (g *Grapher) Def(vname, rrdfile, dsname, cf string, options ...string)

func (*Grapher) GPrint Uses

func (g *Grapher) GPrint(vname, format string)

func (*Grapher) GPrintT Uses

func (g *Grapher) GPrintT(vname, format string)

func (*Grapher) Graph Uses

func (g *Grapher) Graph(start, end time.Time) (GraphInfo, []byte, error)

Graph returns GraphInfo and image as []byte or error

func (*Grapher) HRule Uses

func (g *Grapher) HRule(value, color string, options ...string)

func (*Grapher) Line Uses

func (g *Grapher) Line(width float32, value, color string, options ...string)

func (*Grapher) Print Uses

func (g *Grapher) Print(vname, format string)

func (*Grapher) PrintT Uses

func (g *Grapher) PrintT(vname, format string)

func (*Grapher) SaveGraph Uses

func (g *Grapher) SaveGraph(filename string, start, end time.Time) (GraphInfo, error)

SaveGraph saves image to file and returns GraphInfo or error

func (*Grapher) SetAltAutoscale Uses

func (g *Grapher) SetAltAutoscale()

func (*Grapher) SetAltAutoscaleMax Uses

func (g *Grapher) SetAltAutoscaleMax()

func (*Grapher) SetAltAutoscaleMin Uses

func (g *Grapher) SetAltAutoscaleMin()

func (*Grapher) SetBase Uses

func (g *Grapher) SetBase(base uint)

func (*Grapher) SetColor Uses

func (g *Grapher) SetColor(colortag, color string)

func (*Grapher) SetDaemon Uses

func (g *Grapher) SetDaemon(daemon string)

func (*Grapher) SetImageFormat Uses

func (g *Grapher) SetImageFormat(format string)

func (*Grapher) SetInterlaced Uses

func (g *Grapher) SetInterlaced()

func (*Grapher) SetLazy Uses

func (g *Grapher) SetLazy()

func (*Grapher) SetLogarithmic Uses

func (g *Grapher) SetLogarithmic()

func (*Grapher) SetLowerLimit Uses

func (g *Grapher) SetLowerLimit(limit float64)

func (*Grapher) SetNoGridFit Uses

func (g *Grapher) SetNoGridFit()

func (*Grapher) SetNoLegend Uses

func (g *Grapher) SetNoLegend()

func (*Grapher) SetRightAxis Uses

func (g *Grapher) SetRightAxis(scale, shift float64)

func (*Grapher) SetRightAxisLabel Uses

func (g *Grapher) SetRightAxisLabel(label string)

func (*Grapher) SetRigid Uses

func (g *Grapher) SetRigid()

func (*Grapher) SetSize Uses

func (g *Grapher) SetSize(width, height uint)

func (*Grapher) SetSlopeMode Uses

func (g *Grapher) SetSlopeMode()

func (*Grapher) SetTitle Uses

func (g *Grapher) SetTitle(title string)

func (*Grapher) SetUnitsExponent Uses

func (g *Grapher) SetUnitsExponent(e int)

func (*Grapher) SetUnitsLength Uses

func (g *Grapher) SetUnitsLength(l uint)

func (*Grapher) SetUpperLimit Uses

func (g *Grapher) SetUpperLimit(limit float64)

func (*Grapher) SetVLabel Uses

func (g *Grapher) SetVLabel(vlabel string)

func (*Grapher) SetWatermark Uses

func (g *Grapher) SetWatermark(watermark string)

func (*Grapher) Shift Uses

func (g *Grapher) Shift(vname string, offset interface{})

func (*Grapher) TextAlign Uses

func (g *Grapher) TextAlign(align string)

func (*Grapher) Tick Uses

func (g *Grapher) Tick(vname, color string, options ...string)

func (*Grapher) VDef Uses

func (g *Grapher) VDef(vname, rpn string)

func (*Grapher) VRule Uses

func (g *Grapher) VRule(t interface{}, color string, options ...string)

type Updater Uses

type Updater struct {
    // contains filtered or unexported fields
}

func NewUpdater Uses

func NewUpdater(filename string) *Updater

func (*Updater) Cache Uses

func (u *Updater) Cache(args ...interface{})

Cache chaches data for later save using Update(). Use it to avoid open/read/write/close for every update.

func (*Updater) SetTemplate Uses

func (u *Updater) SetTemplate(dsName ...string)

func (*Updater) Update Uses

func (u *Updater) Update(args ...interface{}) error

Update saves data in RRDB. Without args Update saves all subsequent updates buffered by Cache method. If you specify args it saves them immediately.

type XportResult Uses

type XportResult struct {
    Start   time.Time
    End     time.Time
    Step    time.Duration
    Legends []string
    RowCnt  int
    // contains filtered or unexported fields
}

func (*XportResult) FreeValues Uses

func (r *XportResult) FreeValues()

FreeValues free values memory allocated by C.

func (*XportResult) ValueAt Uses

func (r *XportResult) ValueAt(legendIndex, rowIndex int) float64

Package rrd imports 11 packages (graph) and is imported by 8 packages. Updated 2017-10-16. Refresh now. Tools for package owners.