Module: Rdeadman::MonitorHosts
- Defined in:
- lib/rdeadman/monitor.rb
Class Method Summary collapse
Class Method Details
.load_hosts_from_config(file) ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/rdeadman/monitor.rb', line 127 def self.load_hosts_from_config(file) hosts = [] File.readlines(file).each do |line| line = line.strip next if line.empty? || line.start_with?("#") hosts << line end hosts end |
.run(config_file, interval) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/rdeadman/monitor.rb', line 107 def self.run(config_file, interval) hosts = load_hosts_from_config(config_file) host_monitors = hosts.map { |host| HostMonitor.new(host, interval) } display = Display.new begin threads = host_monitors.map do |monitor| Thread.new { monitor.monitor } end loop do display.draw(host_monitors) sleep interval end ensure display.close threads.each(&:kill) end end |