class Naginata::CLI::Hosts
Public Instance Methods
run()
click to toggle source
# 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