Sha256: f92a3623759c0acbb1188214bfcac8544f280f5c89d444d976599fee0fdd4bca

Contents?: true

Size: 1.53 KB

Versions: 44

Compression:

Stored size: 1.53 KB

Contents

require 'fog/core/collection'
require 'fog/rackspace/models/monitoring/data_point'

module Fog
  module Rackspace
    class Monitoring
      class DataPoints < Fog::Collection

        attribute :metric

        model Fog::Rackspace::Monitoring::DataPoint

        def all
          self.fetch(:resolution => :full)
        end

        # Fetch the datapoints for a metric
        # ==== Parameters
        #
        # * options<~Hash> - optional paramaters
        #   * from<~Integer> - timestamp in milliseconds
        #   * to<~Integer> - timestamp in milliseconds
        #   * points<~Integer> - Number of points to fetch
        #   * resolution<~String> - Should be one of :full, :min5, :min20, :min60, :min240, :min1440
        #   * select<~Array> - Should be an array of :average, :max, :min, :variance
        #
        # ==== Returns
        # * datapoints<~Fog::Rackspace::Monitoring::Datapoints>:
        def fetch(options={})
          requires :metric
          options[:from] ||= (Time.now.to_i * 1000) - (3600 * 1000)
          options[:to] ||= Time.now.to_i * 1000
          options[:points] ||= 1 unless options[:resolution]
          if options[:resolution]
            options[:resolution] = options[:resolution].upcase
          end
          data = service.list_data_points(metric.check.entity.id, metric.check.id, metric.name, options).body['values']
          load(data)
        end

        def new(attributes = {})
          requires :metric
          super({ :metric => metric }.merge!(attributes))
        end

      end
    end
  end
end

Version data entries

44 entries across 44 versions & 3 rubygems

Version Path
fog-1.22.0 lib/fog/rackspace/models/monitoring/data_points.rb
fog-1.21.0 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/rackspace/models/monitoring/data_points.rb
fog-1.20.0 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/rackspace/models/monitoring/data_points.rb
fog-1.19.0 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/rackspace/models/monitoring/data_points.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/rackspace/models/monitoring/data_points.rb