rrdlite

package module
v0.0.0-...-83774f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2016 License: BSD-3-Clause Imports: 9 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go (golang) for rrdtool(1.4.9)

一个轻量级的rrdtool工具包,线程安全,解除librrd依赖,只提供create,update,fetch,info

Installing

go get github.com/yubo/rrdlite

Benchmark

#enable mmap
$go test -bench=Add
#or
$go test -bench=.

...
#cgo CFLAGS: -std=c99 -DRRD_LITE -D_BSD_SOURCE -DHAVE_CONFIG_H -D_POSIX_SOURCE -DNUMVERS=1.4009
BenchmarkAdd-4            100000             49386 ns/op
BenchmarkUpdate-4         100000             19366 ns/op
BenchmarkFetch-4          100000             10956 ns/op

#cgo CFLAGS: -std=c99 -DRRD_LITE -D_BSD_SOURCE -DHAVE_CONFIG_H -D_POSIX_SOURCE -DNUMVERS=1.4009 -DUSE_STDIO=1
BenchmarkAdd-4            100000             56381 ns/op
BenchmarkUpdate-4         100000             21609 ns/op
BenchmarkFetch-4          100000             17339 ns/op

#cgo CFLAGS: -std=c99 -DRRD_LITE -D_BSD_SOURCE -DHAVE_CONFIG_H -D_POSIX_SOURCE -DNUMVERS=1.4009 -DHAVE_MMAP
BenchmarkAdd-4            100000             50000 ns/op
BenchmarkUpdate-4         100000             13741 ns/op
BenchmarkFetch-4          100000             11005 ns/op

Example

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

Documentation

Overview

*Copyright 2016 yubo. All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the LICENSE file.

*Copyright 2016 yubo. All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the LICENSE file.

Index

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{})

func (*Creator) RRA

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

type Error

type Error string

func (Error) Error

func (e Error) Error() 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 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址