Class: Nrcmd::Apps::Hosts::Metrics
- Inherits:
-
Thor
- Object
- Thor
- Nrcmd::Apps::Hosts::Metrics
- Defined in:
- lib/nrcmd/apps/hosts/metrics.rb
Constant Summary collapse
- URL =
'https://api.newrelic.com/v2'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.banner(task, namespace = false, subcommand = true) ⇒ Object
54 55 56 |
# File 'lib/nrcmd/apps/hosts/metrics.rb', line 54 def self.(task, namespace = false, subcommand = true) super end |
Instance Method Details
#get(app_id, host_id) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/nrcmd/apps/hosts/metrics.rb', line 42 def get(app_id, host_id) uri = URL + "/applications/#{app_id}/hosts/#{host_id}/metrics/data.json" filter_param = "" filter_param << "names[]=#{['names']}&" filter_param << "values[]=#{['values']}&" if !!['values'] filter_param << "summarize=#{['summarize']}&" filter_param << "from=#{["from"]}&" if !!["from"] filter_param << "to=#{["to"]}&" if !!["to"] res = Nrcmd::Http.get(uri, {}, filter_param) result = JSON.parse(res.body) print JSON[ result ] end |
#list(app_id, host_id) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nrcmd/apps/hosts/metrics.rb', line 16 def list(app_id, host_id) uri = URL + "/applications/#{app_id}/hosts/#{host_id}/metrics.json" filter_param = "" ["filter"].gsub(" ", "").split(',').each do |filter| fkv = filter.split('=') filter_param << "#{fkv[0]}=#{fkv[1]}&" end res = Nrcmd::Http.get(uri, {}, filter_param) result = JSON.parse(res.body) print JSON[ result ] end |