class CloudWatchMetrics::Linux
Constants
- DEFAULT_METRICS
- DEFAULT_NAMESPACE
- VERSION
Public Class Methods
new( namespace: DEFAULT_NAMESPACE, dimensions: {}, metrics: {}, interval: nil, dry_run: false )
click to toggle source
# File lib/cloud_watch_metrics/linux.rb, line 54 def initialize( namespace: DEFAULT_NAMESPACE, dimensions: {}, metrics: {}, interval: nil, dry_run: false ) @namespace = namespace @dimensions = dimensions @metrics = DEFAULT_METRICS.merge(metrics) @interval = interval @dry_run = dry_run end
Private Class Methods
option_parser()
click to toggle source
# File lib/cloud_watch_metrics/linux.rb, line 38 def option_parser OptionParser.new do |opt| Util.accept_hash(opt) opt.on('--namespace <namespace>', String) opt.on('--dimensions <name1=value1,name2=value2,...>', Hash) DEFAULT_METRICS.each_key do |key| opt.on("--[no-]#{key.to_s.tr('_', '-')}", TrueClass) end opt.on('--interval <seconds>', Float) opt.on('--dry-run', TrueClass) end end
parse_arguments(args)
click to toggle source
# File lib/cloud_watch_metrics/linux.rb, line 30 def parse_arguments(args) {}.tap do |options| option_parser.parse(args, into: options) Util.convert_symbol_keys_from_dash_to_underscore!(options) options[:metrics] = Util.delete_keys!(options, DEFAULT_METRICS.keys) end end
Private Instance Methods
builder()
click to toggle source
# File lib/cloud_watch_metrics/linux.rb, line 75 def builder @_builder ||= Builder.new(@dimensions, @metrics) end
run_once()
click to toggle source
# File lib/cloud_watch_metrics/linux.rb, line 70 def run_once metric_data = builder.build(MemInfo.new, LoadAvg.new) Util.put_metric_data(@namespace, metric_data, dry_run: @dry_run) end