Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - #~~~~~~~~~~~~~~~~~~~~~~~
 - # Linux HW Scanner is a simple script to catch all Hardware Specifications from list of servers
 - # Coded by : Sabry Saleh
 - # License : GPL2
 - #~~~~~~~~~~~~~~~~~~~~~~~
 - #=-Notes-=
 - # You have to install ruby + net-ssh gems
 - # sudo gem install net-ssh
 - #~~~~~~~~~~~~~~~~~~~~~~~
 - require 'net/ssh'
 - class LinxHWSpecs
 - begin
 - host = IO.readlines('done1.txt') # full path of servers' list
 - port = 22 # SSH port
 - user = 'root' # username
 - pass = "p@ass20rd" # password
 - i = 0
 - 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,$2,$3,$4}'", # Disk Info(GB)
 - "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 , :verbose=> :error ) 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 @ #{host[i].chomp} : #{e}"
 - end # end of begin
 - end # end of LinxHWSpecs
 
                    Add Comment                
                
                        Please, Sign In to add comment