Skip to content

Commit

Permalink
Add recently added cpu_cores_allocated_metric and memory_allocated_me…
Browse files Browse the repository at this point in the history
…tric

- we are probably allowing both names of metric
  • Loading branch information
lpichler committed Oct 30, 2017
1 parent 2dbdaa2 commit b1298f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/chargeback/consumption_with_rollups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def avg(metric, sub_metric = nil)

def current_value(metric, _sub_metric) # used for containers allocated metrics
case metric
when 'derived_vm_numvcpu_cores' # Allocated CPU count
when 'derived_vm_numvcpu_cores', 'derived_vm_numvcpus_cores' # Allocated CPU count
resource.try(:limit_cpu_cores).to_f
when 'derived_memory_available'
resource.try(:limit_memory_bytes).to_f / 1.megabytes # bytes to megabytes
Expand Down
5 changes: 5 additions & 0 deletions app/models/metering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def calculate_costs(consumption, _)
source = 'used'
end

if field == 'cpu_cores_allocated_metric'
group = 'cpu_cores'
source = 'allocated'
end

chargable_field = ChargeableField.find_by(:group => group, :source => source)
next if field == "existence_hours_metric" || field == "fixed_compute_metric" || chargable_field && chargable_field.metering?
value = chargable_field.measure_metering(consumption, @options) if chargable_field
Expand Down
12 changes: 7 additions & 5 deletions app/models/metering_container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ class MeteringContainerImage < ChargebackContainerImage

def self.report_col_options
{
"cpu_cores_used_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
"metering_used_metric" => {:grouping => [:total]},
"net_io_used_metric" => {:grouping => [:total]},
"cpu_cores_allocated_metric" => {:grouping => [:total]},
"cpu_cores_used_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_allocated_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
"metering_used_metric" => {:grouping => [:total]},
"net_io_used_metric" => {:grouping => [:total]},
}
end

Expand Down

0 comments on commit b1298f9

Please sign in to comment.