Module: Cloudscopes

Defined in:
lib/cloudscopes.rb,
lib/cloudscopes/ec2.rb,
lib/cloudscopes/redis.rb,
lib/cloudscopes/memory.rb,
lib/cloudscopes/sample.rb,
lib/cloudscopes/system.rb,
lib/cloudscopes/network.rb,
lib/cloudscopes/options.rb,
lib/cloudscopes/process.rb,
lib/cloudscopes/version.rb,
lib/cloudscopes/filesystem.rb,
lib/cloudscopes/configuration.rb

Defined Under Namespace

Modules: StatFs Classes: Ec2, Filesystem, Memory, Network, Options, Process, RedisClient, Sample, System

Constant Summary collapse

VERSION =
"0.9.4"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#should_publishObject (readonly)

Returns the value of attribute should_publish.



3
4
5
# File 'lib/cloudscopes/configuration.rb', line 3

def should_publish
  @should_publish
end

#usage_requestedObject (readonly)

Returns the value of attribute usage_requested.



3
4
5
# File 'lib/cloudscopes/configuration.rb', line 3

def usage_requested
  @usage_requested
end

Class Method Details

.clientObject



29
30
31
# File 'lib/cloudscopes/configuration.rb', line 29

def self.client
  @client ||= initClient
end

.data_dimensionsObject



39
40
41
# File 'lib/cloudscopes/configuration.rb', line 39

def self.data_dimensions
  @settings['dimensions'] || ({ 'InstanceId' => '#{ec2.instance_id}' })
end

.get_bindingObject



24
25
26
# File 'lib/cloudscopes.rb', line 24

def self.get_binding
  return binding()
end

.initObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/cloudscopes/configuration.rb', line 5

def self.init
  @opts = Cloudscopes::Options.new
  usage if usage_requested
  configuration = {}
  (@opts.files.empty?? [ STDIN ] : @opts.files.collect { |fn| File.new(fn) }).each do |configfile|
    configuration.merge! YAML.load(configfile.read)
  end
  @settings = configuration['settings']
  configuration['metrics']
end

.initClientObject



33
34
35
36
37
# File 'lib/cloudscopes/configuration.rb', line 33

def self.initClient
  AWS::CloudWatch.new access_key_id: @settings['aws-key'],
                        secret_access_key: @settings['aws-secret'],
                        region: @settings['region']
end

.method_missing(*args) ⇒ Object



28
29
30
# File 'lib/cloudscopes.rb', line 28

def self.method_missing(*args)
  Cloudscopes.const_get(args.shift.to_s.capitalize).new(*args)
end

.redis(host = 'localhost', port = 6379) ⇒ Object



29
30
31
32
# File 'lib/cloudscopes/redis.rb', line 29

def self.redis(host = 'localhost', port = 6379)
  require 'redis'
  RedisClient.new(host,port)
end

.should_publishObject



20
21
22
# File 'lib/cloudscopes/configuration.rb', line 20

def self.should_publish
  @opts.publish != false
end

.systemObject

must define, otherwise kernel.system matches



42
43
44
# File 'lib/cloudscopes/system.rb', line 42

def self.system # must define, otherwise kernel.system matches
  System.new
end

.usageObject



24
25
26
27
# File 'lib/cloudscopes/configuration.rb', line 24

def self.usage
  puts "#{@opts}"
  exit 5
end

.usage_requestedObject



16
17
18
# File 'lib/cloudscopes/configuration.rb', line 16

def self.usage_requested
  @opts.usage
end