Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9144397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:15:34+00:00 2026-06-17T10:15:34+00:00

I’m trying to call RRD.create in Ruby. My RRD variables are stored in a

  • 0

I’m trying to call RRD.create in Ruby. My RRD variables are stored in a hash and I need to construct an RRD.create call. Here is my code:

pool_map = {
  "cleanup"  => "Cleaning up",
  "leased" => "Leased",
  "ready"  => "Ready"
}

start = Time.now.to_i
ti = 60 # time interval, in seconds

RRD.create(
         rrdfile,
         "--start", "#{start - 1}",
         "--step",  ti, # seconds
         pool_map.keys.map{|val| "DS:#{val}:GAUGE:#{ti * 2}:0:U" }.collect,
         "RRA:LAST:0.5:1:#{86400 / ti}",         # detailed values for last 24 hours
         "RRA:AVERAGE:0.5:#{5*60 / ti}:#{7*24*60}", # 5 min averages for 7 days
         "RRA:MAX:0.5:#{5*60 / ti}:#{7*24*60}",     # 5 min maximums for 7 days
         "RRA:AVERAGE:0.5:#{60*60 / ti}:#{183*24}", # 1 hour averages for a half of the year
         "RRA:MAX:0.5:#{60*60 / ti}:#{183*24}"      # 1 hour maximums for a half of the year
        )

However, I’m getting the following error from Ruby:

in `create': invalid argument - Array, expected T_STRING or T_FIXNUM on index 5 (TypeError)

I need to specify a several strings to RRD.create instead of passing array. How can I do this in Ruby?

P.S. http://oss.oetiker.ch/rrdtool/prog/rrdruby.en.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:15:35+00:00Added an answer on June 17, 2026 at 10:15 am

    You want the “splat” operator (unary asterisk):

    *pool_map.keys.map{|val| ...}
    

    Note that you don’t need the collect at the end there, it does nothing! collect is just an alias for map, and you aren’t doing anything with it because you haven’t passed it a block.

    Splat is really useful for destructuring arrays:

    arr = [1, 2, 3]
    a, b, c = *arr
    # a = 1; b = 2; c = 3
    

    And you can often use it to supply arguments to methods, like you are trying to do

    def sum_three_numbers(x, y, z)
      x + y + z
    end
    
    arr = [1, 2, 3]
    sum_three_numbers(*arr)
    # => 6
    
    arr = [1, 2]
    sum_three_numbers(100, *arr)
    # => 103
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.