Bindings to rrdtool

Related tags

Data Processing rrd
Overview

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.

Issues
  • Calling Update results in Panic

    Calling Update results in Panic

    I'm not entirely sure this is an issue, or my wrong understanding on how to use the library. When i call Update(time.Now(),1234) i get a panic: panic: runtime error: cgo argument has Go pointer to Go pointer

    Here's a snippet of my code:

    u := rrd.NewUpdater(fname)
        tstamp, ok := time.Parse("2006-01-02 03:04:05.000000", timestamp)
        if ok != nil {
            Info.Println("Error parsing timestamp \"" + timestamp + "\"")
            tstamp = time.Now()
        }
        u.SetTemplate("a")
        err := u.Update(tstamp,reading)
        if err != nil {
            Error.Println(err)
        }
    

    I've verified that the filename used to initialize the call to NewUpdater is in fact a string (and correct), and the types of the parameters in the call are time.Time and float64.

    it appears to happen in the following code (src/github.com/ziutek/rrd/rrd_c.go:69 +0x100 github.com/ziutek/rrd.(*Updater).Update(0xc820129c38, 0x0, 0x0, 0x0, 0x0, 0x0))

    func (u *Updater) update(args []unsafe.Pointer) error {
        e := C.rrdUpdate(
            (*C.char)(u.filename.p()),
            (*C.char)(u.template.p()),
            C.int(len(args)),
            (**C.char)(unsafe.Pointer(&args[0])),
        )
        return makeError(e)
    }
    
    opened by jinie 5
  • how to use  the func (g *Grapher) Comment(s string)

    how to use the func (g *Grapher) Comment(s string)

    I use the func (g *Grapher) Comment(s string),but i found it not have wrap,I use g.Comment("\n") have no wrap,how can i do? I see the rrdtool sites is "/n".

    opened by canghai908 3
  • Handle numeric DS names

    Handle numeric DS names

    Hi,

    I just made a change in order to handle fully numeric DS names in RRD entries. By example, having:

    ds[42].index = 0
    ds[42].type = "DERIVE"
    ds[42].minimal_heartbeat = 600
    ds[42].min = 0.0000000000e+00
    ds[42].max = NaN
    ds[42].last_ds = "57447256"
    ds[42].value = 1.4651162791e+01
    ds[42].unknown_sec = 0
    

    currently fills ds.index map with a lot of []interface{}(nil).

    With the patch, we verify that kname doesn't start with ds., avoiding the Atoi conversion for ds.* entries and keeping the -1 key id.

    Let me know what do you think of this patch.

    Regards,

    opened by vbatoufflet 3
  • Error with VRule

    Error with VRule

    If the argument t is "time.Time", a crash occured with a message like this : parameter '%!s(int64=1421794800)' does not represent time in line VRULE:%!s(int64=1421794800)#ff0000

    You shouldn't use "%s" parameter in Sprintf because v.Unix() return int64, not a string

    func (g *Grapher) VRule(t interface{}, color string, options ...string) { if v, ok := t.(time.Time); ok { t = v.Unix() } vr := fmt.Sprintf("VRULE:%s#%s", t, color) g.push(vr, options) }

    opened by mlgd 1
  • return values from FetchResult as []float64

    return values from FetchResult as []float64

    Suggested diff:

    diff --git a/rrd_c.go b/rrd_c.go
    index 348c017..9ff5a60 100644
    --- a/rrd_c.go
    +++ b/rrd_c.go
    @@ -457,6 +457,14 @@ func (r *FetchResult) FreeValues() {
        C.free(unsafe.Pointer(sliceHeader.Data))
     }
    
    +
    +// Get a copy of the (c-)values of a FetchResult as slice
    +func (r *FetchResult) GetValues() []float64 {
    +   ret := make([]float64,len(r.values))
    +   copy(ret,r.values)
    +   return ret
    +}
    +
     // Export data from RRD file(s)
     func (e *Exporter) xport(start, end time.Time, step time.Duration) (XportResult, error) {
        cStart := C.time_t(start.Unix())
    
    opened by oec 1
  • Add RRD `xport' support.

    Add RRD `xport' support.

    Hi,

    I added RRDtool xport support:

    • Add new Exporter struct to handle xport (mimicking existing Creator, Grapher, ...)
    • Update unit tests to perform some base tests for the new feature

    Could you please review this pull request and let me know if it suits to you?

    Regards

    opened by vbatoufflet 1
  • Grapher.AddOptions feature; xport row count fix

    Grapher.AddOptions feature; xport row count fix

    Hi, Please review two commits:

    1. Grapher.AddOptions allows set arbitrary options like --border or --full-size-mode
    2. The row count in rrd_xport.c is: row_cnt = ((_end) - (_start)) / (*step); Hence +1 is excess in rowCnt calculations and gives one unassigned value.
    opened by valobanov 0
  • Use pkg-config to handle cgo build flags

    Use pkg-config to handle cgo build flags

    Hi,

    I just made a change in order to use pkg-config to handle the various build flags needed by the cgo compilation (CFLAGS, LDFLAGS...).

    It helps to build the package with on OSes having librrd in a custom location (e.g. rrdtool using brew under Mac OS).

    Let me know if this PR is ok for you.

    Regards

    opened by vbatoufflet 0
  • Add base rrdcached support for `graph' and `xport'

    Add base rrdcached support for `graph' and `xport'

    Hi,

    I added base support for rrdcached daemon parameters.

    As today, the support is only added to the graph and xport commands. I guess it will need some extra changes (embedded Cache method) to implement it on fetch and update.

    Let me know if this is ok for you.

    Regards,

    Vincent

    opened by vbatoufflet 0
  • Add various missing options to Grapher

    Add various missing options to Grapher

    This patch adds following missing options to grapher/fixes a typo (Legand -> Legend) and formats README.md

    -a (imageformat [string]) Image format [PNG | SVG | EPS | PDF] for the generated graph.

    -i (interlaced [bool])

    If images are interlaced they become visible on browsers more quickly.

    -b (base [value])

    If you are graphing memory (and NOT network traffic) this switch should be set to 1024 so that one Kb is 1024 byte. For traffic measurement, 1 kb/s is 1000 b/s.

    -W (watermark [string])

    Adds the given string as a watermark, horizontally centered, at the bottom of the graph.

    opened by caglar10ur 0
  • Get one more unexpect result after fetch

    Get one more unexpect result after fetch

    There is one more value return when fetch the RRD file.

    Here is result with rrdtool 1.4.x:

    [email protected]:/opt/cacti/rra# rrdtool fetch local_linux_machine_proc_1.rrd AVERAGE -s now-10m -e now-10m
                               proc
    
    1628756100: 3.1206666667e+01
    

    Here is result with rrd go 0.0.3:

    [[email protected] rrd]# go run main.go /tmp/rra/local_linux_machine_proc_1.rrd
    2021/08/12 15:24:32 2021-08-12 15:14:32.7134773 +0700 +07 m=-599.999935099
    2021/08/12 15:24:32 Start: 2021-08-12 15:10:00 +0700 +07
    2021/08/12 15:24:32 End: 2021-08-12 15:15:00 +0700 +07
    2021/08/12 15:24:32 Step: 5m0s
    2021/08/12 15:24:32 RowCnt: 2
    2021/08/12 15:24:32 DsNames  : [proc]
    2021/08/12 15:24:32 {Filename:/tmp/rra/local_linux_machine_proc_1.rrd Cf:AVERAGE Start:2021-08-12 15:10:00 +0700 +07 End:2021-08-12 15:15:00 +0700 +07 Step:5m0s DsNames:[proc] RowCnt:2 values:[31.206666666666667 0]}
    
    opened by tuanden0 0
  • Linkage against librrd_th

    Linkage against librrd_th

    Hello,

    By default, my project links against not thread safe libbrrd that causes mess with errors from different Update() calls. Changing #cgo pkg-config: librrd directive to #cgo LDFLAGS: -lrrd_th in rrd_c.go fixes the issue. What is the suggested way to link against thread safe library when using pkg-config?

    This commit switched setting of linker options to pkg-config for the reason not clear from the comment.

    Thanks, Vadim

    opened by valobanov 1
  • Support for rrdtool 1.5.x (crashes now)

    Support for rrdtool 1.5.x (crashes now)

    Dear Michał,

    As Facette uses your rrd library for golang I experienced crashes when my ArchLinux system upgraded to rrdtool 1.4.x to 1.5.x. Is there any chance you will add extra support for rrdtool 1.5.x in the future?

    Here is the original issue: https://github.com/facette/facette/issues/207

    Kind regards, Jerry

    opened by xor-gate 7
  • Added compatibility for RRDtool 1.3.x, Added missing include

    Added compatibility for RRDtool 1.3.x, Added missing include

    • Fixed missing include warning (gcc 4.4.7-11 RHEL 6)
    • Added compatibility for RRDtool 1.3.x line (RRDtool 1.3.x does not export rrd_info_r)

    Reasons:

    • RHEL 6 still uses RRDtool 1.3.8 in the default "supported" repositories. RHEL 6 will be supported until 2020 (End of "Production Phase 3", https://access.redhat.com/support/policy/updates/errata).

    Check:

    • This patch enables the RRDtool 1.3.x workaround PER DEFAULT. Please check if this breaks anything with the 1.4.x line, as I do not have access to any RRDtool 1.4.x

    This patch is equivalent to: https://github.com/bbczeuz/facette/commit/3bf5c15ce7963ce3eea7943f939901bb709f3918

    opened by bbczeuz 1
  • Segfault in rrd.Info()

    Segfault in rrd.Info()

    Hello,

    i was playing around with your rrd package and produced some segfaults using the rrd.Info() function with rrdtool 1.4.8.

    Here is my sample program:

    package main
    
    import (
      "fmt"
      "os"
      "github.com/ziutek/rrd"
    )
    
    func main() {
      info, err := rrd.Info(os.Args[1])
    
      if err != nil {
        fmt.Println(err)
        os.Exit(1)
      }
    
      for k, v := range info {
        fmt.Println(k, ":", v)
      }
    }
    

    And the trace:

    unexpected fault address 0x0
    fatal error: fault
    [signal 0xb code=0x80 addr=0x0 pc=0x42087a]
    
    goroutine 1 [running]:
    runtime.throw(0x781b57)
        /usr/lib/go/src/pkg/runtime/panic.c:464 +0x69 fp=0x7f686fd00c20
    runtime.sigpanic()
        /usr/lib/go/src/pkg/runtime/os_linux.c:237 +0xe9 fp=0x7f686fd00c38
    runtime.findnull(0x208d88000000000)
        /usr/lib/go/src/pkg/runtime/string.goc:22 +0x1a fp=0x7f686fd00c48
    runtime.gostring(0x7f686fd00ca0, 0x208d88000000000)
        /usr/lib/go/src/pkg/runtime/string.goc:67 +0x27 fp=0x7f686fd00c80
    github.com/ziutek/rrd._Cfunc_GoString(0x208d88000000000, 0x10, 0x0)
        github.com/ziutek/rrd/_obj/_cgo_defun.c:11 +0x31 fp=0x7f686fd00c98
    github.com/ziutek/rrd.updateInfoValue(0x208d850, 0x0, 0x0, 0x8, 0x4e8580)
        /home/ushi/.go/src/github.com/ziutek/rrd/rrd_c.go:295 +0xd7 fp=0x7f686fd00d28
    github.com/ziutek/rrd.parseRRDInfo(0x208d850, 0x0)
        /home/ushi/.go/src/github.com/ziutek/rrd/rrd_c.go:341 +0x477 fp=0x7f686fd00e08
    github.com/ziutek/rrd.Info(0x7fff9e62c9cf, 0x8, 0x0, 0x0, 0x0)
        /home/ushi/.go/src/github.com/ziutek/rrd/rrd_c.go:408 +0xe4 fp=0x7f686fd00e38
    main.main()
        /tmp/test.go:10 +0x52 fp=0x7f686fd00f48
    runtime.main()
        /usr/lib/go/src/pkg/runtime/proc.c:220 +0x11f fp=0x7f686fd00fa0
    runtime.goexit()
        /usr/lib/go/src/pkg/runtime/proc.c:1394 fp=0x7f686fd00fa8
    
    goroutine 3 [syscall]:
    runtime.goexit()
        /usr/lib/go/src/pkg/runtime/proc.c:1394
    exit status 2
    

    Tell me, if you need the rrd file or additional info. My first guess is, that the string is not properly 0 terminated, but it is just a guess.

    Cheers, ushi

    opened by ushis 2
Owner
Michał Derkacz
Michał Derkacz
Graph and alert on '.rrd' data using grafana, RRDTool and RRDSrv.

Grafana RRD Datasource A grafana datasource for reading '.rrd' files via RRDTool and RRDsrv. With this datasource you will be able to create grafana d

null 9 Jun 7, 2022
libsox bindings for go

gosox "SoX − Sound eXchange, the Swiss Army knife of audio manipulation" Go bindings for the libsox sound library For more information and documentati

Kristoffer Grönlund 123 Apr 9, 2022
Go bindings for the PortAudio audio I/O library

portaudio This package provides an interface to the PortAudio audio I/O library. See the package documentation for details. To build this package you

Gordon Klaus 507 Jun 20, 2022
Go bindings for libportmidi

portmidi Want to output to an MIDI device or listen your MIDI device as an input? This package contains Go bindings for PortMidi. libportmidi (v. 217)

Jaana Dogan 267 Jun 28, 2022
Golang bindings for the Telegram Bot API

Golang bindings for the Telegram Bot API All methods are fairly self explanatory, and reading the godoc page should explain everything. If something i

null 3.8k Jun 29, 2022
OpenSSL bindings for Go

OpenSSL bindings for Go Please see http://godoc.org/github.com/spacemonkeygo/openssl for more info License Copyright (C) 2017. See AUTHORS. Licensed u

Space Monkey Go 436 Jun 1, 2022
Golang bindings for libxlsxwriter for writing XLSX files

goxlsxwriter provides Go bindings for the libxlsxwriter C library. Install goxlsxwriter requires the libxslxwriter library to be installe

Frank Terragna 18 Jun 27, 2022
Go bindings for ForestDB

goforestdb Go bindings for ForestDB Building Obtain and build forestdb: https://github.com/couchbaselabs/forestdb (run make install to install the lib

null 32 Apr 5, 2022
Go bindings for GLib type system.

Go bindings for GLib type system. This package is designed for building bindings to C libraries based on GLib type system (like GTK, GStreamer, and ot

Michał Derkacz 24 Aug 13, 2019
Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files.

tabby Source code editor written in Go using go-gtk bindings. It aims to handle navigation effectively among large number of files. screenshot: depend

Mikhail Trushnikov 49 Dec 30, 2021
Duktape JavaScript engine bindings for Go

Duktape bindings for Go(Golang) Duktape is a thin, embeddable javascript engine. Most of the api is implemented. The exceptions are listed here. Usage

Oleg Lebedev 779 Jun 14, 2022
PHP bindings for the Go programming language (Golang)

PHP bindings for Go This package implements support for executing PHP scripts, exporting Go variables for use in PHP contexts, attaching Go method rec

Alex Palaistras 862 Jun 26, 2022
naive go bindings to the CPython C-API

go-python Naive go bindings towards the C-API of CPython-2. this package provides a go package named "python" under which most of the PyXYZ functions

Sebastien Binet 1.4k Jun 24, 2022
Go bindings for Lua C API - in progress

Go Bindings for the lua C API Simplest way to install: # go get github.com/aarzilli/golua/lua You can then try to run the examples: $ cd golua/_examp

Alessandro Arzilli 588 Jun 13, 2022
Go bindings for libmagic to detect MIME types

magicmime magicmime is a Go package which allows you to discover a file's mimetype by looking for magic numbers in its content. It could be used as a

Jaana Dogan 208 Jun 4, 2022
Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

raylib-go Golang bindings for raylib, a simple and easy-to-use library to enjoy videogames programming. Requirements Ubuntu X11 apt-get install libgl1

Milan Nikolic 810 Jun 22, 2022
Go bindings for the Cartographic Projections Library PROJ.4

The Go package proj provides a limited interface to the Cartographic Projections Library PROJ. For PROJ version 5 and beyond, see also: https://github

Peter Kleiweg 41 Dec 8, 2021
Go bindings for GLFW 3

GLFW 3.3 for Go Installation GLFW C library source is included and built automatically as part of the Go package. But you need to make sure you have d

OpenGL with Golang 1.3k Jun 24, 2022
Go bindings for GLFW 3

GLFW 3.3 for Go Installation GLFW C library source is included and built automatically as part of the Go package. But you need to make sure you have d

OpenGL with Golang 1.3k Jun 22, 2022
Go bindings for OpenGL (generated via glow)

gl This repository holds Go bindings to various OpenGL versions. They are auto-generated using Glow. Features: Go functions that mirror the C specific

OpenGL with Golang 911 Jun 26, 2022
Go bindings to OpenGL Utility Library

GLU This package offers minimal bindings for GLU functions. Usage go get github.com/go-gl-legacy/glu License Copyright 2012 The go-gl Authors. All ri

go-gl legacy 21 Aug 18, 2018
Go bindings for audio capture and playback with ALSA and libasound

Go ALSA bindings These bindings allow capture and playback of audio via ALSA using the alsa-lib library. Installation go get github.com/cocoonlife/goa

null 35 Mar 21, 2022
naive go bindings to GnuPlot

go-gnuplot Simple-minded functions to work with gnuplot. go-gnuplot runs gnuplot as a subprocess and pushes commands via the STDIN of that subprocess.

Sebastien Binet 26 Nov 8, 2021
go-gtk3 - GTK3 BINDINGS FOR GO

go-gtk3 - GTK3 BINDINGS FOR GO THIS IS: Hopefully GTK3 Bindings using gobject binding for Go. Goal is to have fairly complete gtk3 widgets with pango

nori satir 57 May 25, 2021
Experimental OpenAL bindings for Go.

Experimental OpenAL bindings for Go. ==================================== Everything is evolving quickly and nothing is totally done. If you want to

Peter H. Fröhlich 29 Apr 8, 2022
Go bindings for OpenCV / 2.x API in gocv / 1.x API in opencv

Go OpenCV binding A Golang binding for OpenCV. OpenCV 1.x C API bindings through CGO, and OpenCV 2+ C++ API (GoCV) through SWIG. Disclaimer This is a

go-opencv 1.3k Jun 28, 2022
Go bindings for GStreamer (retired: currently I don't use/develop this package)

Retired. I don't use/develop this package anymore. Go bindings for GStreamer at a very early stage of maturity. This package is based on GLib bindings

Michał Derkacz 164 May 31, 2022
Go bindings for libVLC and high-level media player interface

Go bindings for libVLC 2.X/3.X/4.X and high-level media player interface. The package can be useful for adding multimedia capabilities to applications

Adrian-George Bostan 306 Jun 16, 2022
Go bindings for OpenCV1.1 (Dev/Zero Dependencies).

Go语言QQ群: 102319854, 1055927514 凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa Go bindings for OpenCV1.1 PkgDoc: http://godoc

chai2010 116 Dec 12, 2021