Class: Naginata::CLI::Hosts
- Inherits:
-
RemoteAbstract
- Object
- RemoteAbstract
- Naginata::CLI::Hosts
- Defined in:
- lib/naginata/cli/hosts.rb
Instance Method Summary collapse
Methods inherited from RemoteAbstract
#configure_backend, #execute, #initialize, #load_configuration, #load_remote_objects, #set_log_level, #set_nagios_filter
Constructor Details
This class inherits a constructor from Naginata::CLI::RemoteAbstract
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/naginata/cli/hosts.rb', line 10 def run if @options[:all_hosts] ::Naginata::Configuration.env.add_filter(:host, :all) else ::Naginata::Configuration.env.add_filter(:host, @options[:patterns]) end table = [] table << %w(NAGIOS HOST STATUS FLAGS OUTPUT) Naginata::Runner.run_locally do |nagios_server, services| targets = services.map{ |s| s.hostname }.uniq status = Status.find(nagios_server.hostname) status.scopes << lambda { |s| targets.any? {|host| s.include?("host_name=#{host}") } } table.concat(status.decorate.hosts_table) end Naginata.ui.print_table(table, truncate: !@options[:wide]) end |