README

Go bindings to rrdtool C library (rrdtool)

This package implements Go (golang) bindings for the rrdtool C API.

Installing

rrd currently supports rrdtool-1.4.x

Install rrd with:

go get github.com/ziutek/rrd

Usage

See GoDoc for documentation.

Example

See rrd_test.go for an example of using this package.

Documentation

Overview

    Simple wrapper for rrdtool C library

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func Info

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

      Info returns information about RRD file.

      Types

      type Creator

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

      func NewCreator

      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

        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

          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.

            Example
            Output:
            
            

            func (*Creator) RRA

            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.

              Example
              Output:
              
              

              type Error

              type Error string

              func (Error) Error

              func (e Error) Error() string

              type Exporter

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

              func NewExporter

              func NewExporter() *Exporter

              func (*Exporter) CDef

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

              func (*Exporter) Def

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

              func (*Exporter) SetDaemon

              func (e *Exporter) SetDaemon(daemon string)

              func (*Exporter) SetMaxRows

              func (e *Exporter) SetMaxRows(maxRows uint)

              func (*Exporter) Xport

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

              func (*Exporter) XportDef

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

              type FetchResult

              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

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

                Fetch retrieves data from RRD file.

                func (*FetchResult) FreeValues

                func (r *FetchResult) FreeValues()

                  FreeValues free values memory allocated by C.

                  func (*FetchResult) ValueAt

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

                  func (*FetchResult) Values

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

                    Values returns copy of internal array of values.

                    type GraphInfo

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

                    type Grapher

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

                    func NewGrapher

                    func NewGrapher() *Grapher

                    func (*Grapher) AddOptions

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

                    func (*Grapher) Area

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

                    func (*Grapher) CDef

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

                    func (*Grapher) Comment

                    func (g *Grapher) Comment(s string)

                    func (*Grapher) Def

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

                    func (*Grapher) GPrint

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

                    func (*Grapher) GPrintT

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

                    func (*Grapher) Graph

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

                      Graph returns GraphInfo and image as []byte or error

                      func (*Grapher) HRule

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

                      func (*Grapher) Line

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

                      func (*Grapher) Print

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

                      func (*Grapher) PrintT

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

                      func (*Grapher) SaveGraph

                      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

                        func (g *Grapher) SetAltAutoscale()

                        func (*Grapher) SetAltAutoscaleMax

                        func (g *Grapher) SetAltAutoscaleMax()

                        func (*Grapher) SetAltAutoscaleMin

                        func (g *Grapher) SetAltAutoscaleMin()

                        func (*Grapher) SetBase

                        func (g *Grapher) SetBase(base uint)

                        func (*Grapher) SetBorder

                        func (g *Grapher) SetBorder(width uint)

                        func (*Grapher) SetColor

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

                        func (*Grapher) SetDaemon

                        func (g *Grapher) SetDaemon(daemon string)

                        func (*Grapher) SetImageFormat

                        func (g *Grapher) SetImageFormat(format string)

                        func (*Grapher) SetInterlaced

                        func (g *Grapher) SetInterlaced()

                        func (*Grapher) SetLazy

                        func (g *Grapher) SetLazy()

                        func (*Grapher) SetLogarithmic

                        func (g *Grapher) SetLogarithmic()

                        func (*Grapher) SetLowerLimit

                        func (g *Grapher) SetLowerLimit(limit float64)

                        func (*Grapher) SetNoGridFit

                        func (g *Grapher) SetNoGridFit()

                        func (*Grapher) SetNoLegend

                        func (g *Grapher) SetNoLegend()

                        func (*Grapher) SetRightAxis

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

                        func (*Grapher) SetRightAxisLabel

                        func (g *Grapher) SetRightAxisLabel(label string)

                        func (*Grapher) SetRigid

                        func (g *Grapher) SetRigid()

                        func (*Grapher) SetSize

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

                        func (*Grapher) SetSlopeMode

                        func (g *Grapher) SetSlopeMode()

                        func (*Grapher) SetTitle

                        func (g *Grapher) SetTitle(title string)

                        func (*Grapher) SetUnitsExponent

                        func (g *Grapher) SetUnitsExponent(e int)

                        func (*Grapher) SetUnitsLength

                        func (g *Grapher) SetUnitsLength(l uint)

                        func (*Grapher) SetUpperLimit

                        func (g *Grapher) SetUpperLimit(limit float64)

                        func (*Grapher) SetVLabel

                        func (g *Grapher) SetVLabel(vlabel string)

                        func (*Grapher) SetWatermark

                        func (g *Grapher) SetWatermark(watermark string)

                        func (*Grapher) Shift

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

                        func (*Grapher) TextAlign

                        func (g *Grapher) TextAlign(align string)

                        func (*Grapher) Tick

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

                        func (*Grapher) VDef

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

                        func (*Grapher) VRule

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

                        type Updater

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

                        func NewUpdater

                        func NewUpdater(filename string) *Updater

                        func (*Updater) Cache

                        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

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

                          func (*Updater) Update

                          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

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

                            func (*XportResult) FreeValues

                            func (r *XportResult) FreeValues()

                              FreeValues free values memory allocated by C.

                              func (*XportResult) ValueAt

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

                              Source Files