morellon / rrd-ffi

A ruby wrapper for librrd (rrdtool) using ffi.
MIT License
71 stars 20 forks source link

Variable as datasource name #12

Closed cimm closed 12 years ago

cimm commented 12 years ago

Hi Thiago,

While checking the fix you released I ran in another problem... It seems you can't assign a datasource with a variable.

some_var = "memory"
rrd.create :start => start_time, :step => 10.minutes do
  datasource some_var, :type => :gauge, :heartbeat => 15.minutes, :min => 0, :max => 100
  archive :average, :every => 20.minutes, :during => 1.month
end

The some_var in the example is the problem. Everything works fine as long as it is a string but once I replace it with a variable he won't create the RRD file anymore:

Invalid DS name

I traced back the problem to the builder in the gem. I suppose the builder.instance_eval does something weird with the variable.

morellon commented 12 years ago

Hi cimm,

As I've tested here, it should work. Which ruby version are you using?

cimm commented 12 years ago

Maybe I missed something. Will investigate a little more. I am on 1.9.3.

cimm commented 12 years ago

You are right, a normal variable works, it only happens when I use an instance variable. Suppose it loses it's context within the block. Probably not something you have to fix. Sorry about that.