Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'yaml'
require 'rubygems'
require 'net/ssh'
require 'net/ssh/version'
places = YAML.load_file('places.yaml')
threads = []
places.each do |place|
threads << Thread.new(place) do |p|
Net::SSH.start(p[:host], p[:login], :password => p[:password]) do |ssh|
puts "connected to #{p[:host]}"
# puts ssh.to_yaml
uptime = ssh.exec!("uptime")
puts uptime
end
end
end
threads.each { |t| t.join }
$ ruby checkmyplaces.rb
connected to eeebox.fridim.org
/usr/lib/ruby/1.8/net/ssh/session.rb:199:in `method_missing': undefined method `exec!' for #<Net::SSH::Session:0xb76fea5c> (NoMethodError)
from checkmyplaces.rb:21:in `join'
from checkmyplaces.rb:21
from checkmyplaces.rb:21:in `each'
from checkmyplaces.rb:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.