lib/cloudstack-nagios/commands/nagios_config.rb in cloudstack-nagios-0.6.1 vs lib/cloudstack-nagios/commands/nagios_config.rb in cloudstack-nagios-0.6.2

- old
+ new

@@ -1,7 +1,9 @@ class NagiosConfig < CloudstackNagios::Base + class_option :bin_path, desc: "absolute path to the nagios-cloudstack binary" + desc "router_hosts", "generate nagios hosts configuration for virtual routers" option :template, desc: "path of ERB template to use", default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_router_hosts.cfg.erb'), aliases: '-t' @@ -46,17 +48,19 @@ desc "storage_pool_services", "generate nagios storage pool services configuration" option :template, desc: "path of ERB template to use", default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_storage_pool_services.cfg.erb'), aliases: '-t' + option :over_provisioning, type: :numeric, default: 1.0 def storage_pool_services service_template = load_template(options[:template]) storage_pools = client.list_storage_pools.select do |pool| pool['state'].downcase == 'up' end puts service_template.result( storage_pools: storage_pools, + over_provisioning: options[:over_provisioning], bin_path: bin_path, config_file: options[:config], date: date_string ) end @@ -80,10 +84,14 @@ def date_string Time.new.strftime("%d.%m.%Y - %H:%M:%S") end def bin_path - File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'bin')) + unless options[:bin_path] + return '' + else + return options[:bin_path].end_with?('/') ? options[:bin_path] : options[:bin_path] + "/" + end end end end \ No newline at end of file