Class: Source::Ceilometer

Inherits:
Source
  • Object
show all
Includes:
Helpers
Defined in:
lib/source/ceilometer.rb

Overview

Constant Summary

Constants included from Helpers

Helpers::REDIS_KEY

Instance Method Summary collapse

Methods included from Helpers

#data_sanitize, #delete_metrics_cache, #get_json, #init_lib, #init_source, #init_store, #interpolate, #is_up?, #json_metrics, #json_metrics_list, #keysplit, #mandatory_param, #optional_param, #origin_settings, #redis_conn, #top_tail_pad

Instance Method Details

#titleize(metric) ⇒ Object

Take a metric metadata string, and return a human readable title


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/source/ceilometer.rb', line 6

def titleize metric
	keys = metric
	nice = []

	display_name = nil

	# Given the metadata for a OpenStack object, this should return human readable metric names
	# Only attempt to use a nicer name if we get sufficient metadata back from our calls
	if keys["metric_name"] then

		# Create a Store object from the settings file to search metrics for us
		store = init_store @settings.store, @origin_id, @settings

		if keys["metric_name"] == "image.download" || keys["metric_name"] == "image.serve" then
			search = store.search_metrics "*gauge*image*#{keys["resource_id"]}*"
			if search.length >= 1
				result = keysplit(search.first)
				display_name = "(#{result["name"]})"
			end
		end
	end

	# If we found a nicer name, use that. Otherwise, try and default it
	if display_name
		nice << display_name
	else
		nice << (keys["display_name"] || keys["name"] || keys["id"])
	end

	nice << keys["metric_name"]
	nice << keys["metric_type"]
	nice << keys["_unit"]

	return URI.decode(nice.delete_if{|a| a.nil?}.join(" - "))
end