Class: JCF::Plugins::AwsRds

Inherits:
Object
  • Object
show all
Defined in:
lib/jcf/plugins/aws_rds.rb

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ AwsRds

Returns a new instance of AwsRds.



12
13
14
15
16
# File 'lib/jcf/plugins/aws_rds.rb', line 12

def initialize(name:)
  @name = name
  @metrics = {}
  check_token!
end

Instance Method Details

#metricsObject



26
27
28
29
30
31
32
33
# File 'lib/jcf/plugins/aws_rds.rb', line 26

def metrics
  @metrics[:storage_used] = to_gb(storage_used(name: @name || ""))
  @metrics[:storage_allocated] = to_gb(storage_allocated(name: @name) || "")
  @metrics[:storage_free] = to_gb(storage_free(name: @name) || "")
  @metrics[:iops] = (iops(name: @name).to_fs(:rounded, precision: 0) || "")
  @metrics[:cpu] = (cpu(name: @name).to_fs(:rounded, precision: 0) || "")
  @metrics
end

#namesObject



18
19
20
# File 'lib/jcf/plugins/aws_rds.rb', line 18

def names
  %w[storage_used storage_allocated storage_free iops cpu]
end

#to_sObject



35
36
37
# File 'lib/jcf/plugins/aws_rds.rb', line 35

def to_s
  metrics.to_s
end

#valuesObject



22
23
24
# File 'lib/jcf/plugins/aws_rds.rb', line 22

def values
  names.map { |name| send(name.to_sym) }
end