RRDRUBY(1)

πŸ’– RRDRUBY(1) πŸ’–

okay so this is the page for rrdruby, like, the Ruby bindings for rrdtool β€” it lives in the rrdtool manual set and honestly? it's a whole vibe. grab a snack, bestie, we're learning Ruby + RRD today πŸ“


✨ NAME ✨

rrdruby β€” the ✨tea✨ on the RRD Ruby bindings, fr fr 🫢


🌸 SYNOPSIS 🌸

require "RRD"
RRD.create(
   rrd,
   "--step", "300",
   "DS:a:GAUGE:600:U:U",
   "DS:b:GAUGE:600:U:U",
   "RRA:AVERAGE:0.5:1:300")

that's it. that's the whole entrance. iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, the rrdtool functions are directly callable through the Ruby programming language β€” no middleman, no drama. this wrapper implementation was written from the scratch (without SWIG), which is lowkey a flex ngl πŸ‘‘

the API simply expects string parameters passed to the functions. that's the whole contract, no cap. and for the actual functions and which arguments are valid? please refer to the other rrdtool documentation β€” that's where the lore lives πŸ“šβœ¨


πŸŽ€ EXAMPLE πŸŽ€

here's a full little demo, copied exactly because we do not mess with code in this house:

$: << '/path/to/rrdtool/lib/ruby/1.8/i386-linux'
require "RRD"

name = "test"
rrd = "#{name}.rrd"
start = Time.now.to_i

RRD.create(
   rrd,
   "--start", "#{start - 1}",
   "--step", "300",
       "DS:a:GAUGE:600:U:U",
   "DS:b:GAUGE:600:U:U",
   "RRA:AVERAGE:0.5:1:300")
puts

puts "updating #{rrd}"
start.to_i.step(start.to_i + 300 * 300, 300) { |i|
   RRD.update(rrd, "#{i}:#{rand(100)}:#{Math.sin(i / 800) * 50 + 50}")
}
puts

puts "fetching data from #{rrd}"
(fstart, fend, data, step) = RRD.fetch(rrd, "--start", start.to_s, "--end",
     (start + 300 * 300).to_s, "AVERAGE")
puts "got #{data.length} data points from #{fstart} to #{fend}"
puts

puts "generating graph #{name}.png"
RRD.graph(
  "#{name}.png",
   "--title", " RubyRRD Demo",
   "--start", "#{start+3600}",
   "--end", "start + 1000 min",
   "--interlaced",
   "--imgformat", "PNG",
   "--width=450",
   "DEF:a=#{rrd}:a:AVERAGE",
   "DEF:b=#{rrd}:b:AVERAGE",
   "CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
   "AREA:b#00b6e4:beta",
   "AREA:line#0022e9:alpha",
   "LINE3:line#ff0000")
puts

so we're creating, updating, fetching, and graphing β€” the full glow-up pipeline πŸ’–πŸ“ˆ


🌈 THE LIL' NOTES SECTION 🌈

  • if you use the --ruby-site-install configure option, you can drop the $: line β€” because the RRDtool module will be found automatically, no manual path-hunting needed ✨
  • and if RRDtool runs into trouble, it will throw an exception, which you might want to catch. like, please catch it. don't just let it scream into the void 😭
fr fr: string parameters only, and catch your exceptions. that's the whole personality 🫢

πŸ’œ SEE ALSO πŸ’œ

rrdcreate, rrdupdate, rrdgraph, rrddump, rrdfetch, rrdtune, rrdlast, rrdxport, rrdinfo

go read them all, they're all bangers πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

LoΓ―s Lherbier <lois.lherbier@covadis.ch>

Miles Egan <miles@caddr.com>

absolute legends, both of them πŸ«‘πŸ’…


and that's the page!! version 1.11.0, dated 2026-10-17 β€” written by the icons above, brought to you by the rrdtool girlies. mwah, go forth and graph πŸŒΈπŸ¦‹πŸ’–

πŸ“¦ where this page comes from