   memoryUsed = []
   memory = []
   cpus = []
-  $forEach cpusIndexes, (value, key) ->
-    cpus[value] = []
   date = [] #TODO
   # TODO: fetch other info: network, IOPS etc.
 
-  # the final object
-  result = {}
 
   $forEach json.rrd.rra[0].database.row, (n, key) ->
     # WARNING! memoryFree is in Kb not in b, memory is in b

  # CPU: fetch every CPUs!
  cpusIndexes = []
  index = 0
  current_cpu = 'cpu'+index
  while $findIndex(json.rrd.ds, 'name': current_cpu) isnt -1
    cpusIndexes.push(index)
    index++
    current_cpu = 'cpu'+index

  memoryFreeIndex = $findIndex(json.rrd.ds, 'name': 'memory_internal_free')
  memoryIndex = $findIndex(json.rrd.ds, 'name': 'memory')

    date.push(key)
    # build the multi dimensional CPUs array
    $forEach cpusIndexes, (value, key) ->
      cpus[key] ?= []
      cpus[key].push(n.v[value]*100)

    return

  # the final object
  return {
    memoryFree: memoryFree
    memoryUsed: memoryUsed
    memory: memory
    date: date
    cpus: cpus
  }

stats.params = {
  id: { type: 'string' }
