Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching data from a rrd #3

Closed
gummybears opened this issue Aug 25, 2010 · 2 comments
Closed

Fetching data from a rrd #3

gummybears opened this issue Aug 25, 2010 · 2 comments
Labels

Comments

@gummybears
Copy link

I am trying to fetch data from a rrd via, but don't know how ?
Here is some code

rrd = RRD::Base.new("myrrd.rrd")
tend = Time.now
tstart = tend - 1.month
tstep = 5.minutes
rrd.create :start => Time.now - 1.year, :step => tstep do
datasource "idle", :type => :gauge, :heartbeat => tstep, :min => 0, :max => 100
datasource "irq", :type => :gauge, :heartbeat => tstep, :min => 0, :max => 100
datasource "softirq", :type => :gauge, :heartbeat => tstep, :min => 0, :max => 100
archive :average, :every => 10.minutes, :during => 1.year
end
t = tstart
while t <= tend
rrd.update t, rand(100),rand(100),rand(100)
t = t + tstep
end

now fetch data each datasource ????

rrd.fetch("idle").each do |line|
.....
end

@morellon
Copy link
Owner

Well, the fetch command gets all data for an archive type not a datasource one.
Try something like this:
rrd.fetch(:average).each {|line| puts line.inspect}

If I am not mistaken, line[0] contains all datasources' titles, the first column in all lines contains the timestamp unix time.

Hope it helps.

@morellon
Copy link
Owner

any questions, just open a new issue.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants