lib/cloudstack-nagios/commands/nagios_config.rb in cloudstack-nagios-0.5.1 vs lib/cloudstack-nagios/commands/nagios_config.rb in cloudstack-nagios-0.6.0
- old
+ new
@@ -1,39 +1,89 @@
class NagiosConfig < CloudstackNagios::Base
- desc "hosts", "generate nagios hosts configuration for virtual routers"
+ 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_routers_hosts.cfg.erb'),
+ default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_router_hosts.cfg.erb'),
aliases: '-t'
- def hosts
+ def router_hosts
host_template = load_template(options[:template])
puts host_template.result(
routers: cs_routers,
date: date_string
)
end
- desc "services", "generate nagios services configuration for virtual routers"
+ desc "router_services", "generate nagios services configuration for system vms"
option :template,
desc: "path of ERB template to use",
- default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_routers_services.cfg.erb'),
+ default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_router_services.cfg.erb'),
aliases: '-t'
- def services
- bin_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'bin'))
- config_file = options[:config]
+ def router_services
service_template = load_template(options[:template])
puts service_template.result(
routers: cs_routers,
bin_path: bin_path,
- config_file: config_file,
+ config_file: options[:config],
date: date_string
)
end
+ desc "api_hosts", "generate nagios api host configuration"
+ option :template,
+ desc: "path of ERB template to use",
+ default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_api_hosts.cfg.erb'),
+ aliases: '-t'
+ def api_hosts
+ service_template = load_template(options[:template])
+ puts service_template.result(
+ zones: client.list_zones,
+ bin_path: bin_path,
+ config_file: options[:config],
+ date: date_string
+ )
+ end
+
+ 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'
+ 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,
+ bin_path: bin_path,
+ config_file: options[:config],
+ date: date_string
+ )
+ end
+
+ desc "capacity_services", "generate nagios capacity services configuration"
+ option :template,
+ desc: "path of ERB template to use",
+ default: File.join(File.dirname(__FILE__), '..', 'templates', 'cloudstack_capacity_services.cfg.erb'),
+ aliases: '-t'
+ def capacity_services
+ service_template = load_template(options[:template])
+ puts service_template.result(
+ capacity_types: Capacity::CAPACITY_TYPES,
+ bin_path: bin_path,
+ config_file: options[:config],
+ date: date_string
+ )
+ end
+
no_commands do
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'))
+ end
end
- end
+ end
\ No newline at end of file