Created
October 29, 2011 14:43
-
-
Save ecleel/1324521 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/ssh' | |
host = IO.readlines('test1.txt') # full path of servers' list | |
port = 22 # SSH port | |
user = 'root' # username | |
pass = "123123" # password | |
i = 0 | |
begin | |
cmd = ["sudo /sbin/ip addr | grep mtu | grep -v lo | awk '{print $2}'", # Interfaces | |
"sudo /sbin/ip addr | grep -i inet | grep -v inet6 | awk '{print $2}' | grep -v 127.0.0.1", # IP-Address(v4) | |
"sudo grep 'name' /proc/cpuinfo | tail -n 1 | cut -d ':' -f 2 | awk '{print $1,$2,$3}'", # CPU Info | |
"sudo /sbin/fdisk -l | grep -i disk | grep -v identifier | sort | grep -v Partition | grep -v md | awk '{print $1 | |
"sudo free -m | grep Mem | awk '{ print $2 }'", # RAM Info (MB) | |
"cat /etc/redhat-release", # Releas Version | |
"hostname"] # Server Name | |
while i < host.length | |
Net::SSH.start( host[i],user,:password => pass, :port=> port ) do |ssh| | |
puts "Server Name: #{ssh.exec!(cmd[6])}" | |
puts "[+] Interfaces: \n#{ssh.exec!(cmd[0])}" | |
puts "[+] IP-Address(v4): \n#{ssh.exec!(cmd[1])} \n" | |
puts "[+] CPU Info: \n#{ssh.exec!(cmd[2])} \n" | |
puts "[+] Disk Info(GB): \n#{ssh.exec!(cmd[3])} \n" | |
puts "[+] RAM Info (MB): \n#{ssh.exec!(cmd[4])} \n" | |
puts "[+] Releas Version: \n#{ssh.exec!(cmd[5])} \n" | |
puts "[*]----------[ End Of #{ssh.exec!(cmd[6].chomp)} ]----------[*]" | |
end # end of do | |
i += 1 | |
end # end of while | |
rescue Exception => e | |
puts "Error!! #{e}" | |
end # end of begin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment