Guest User

Untitled

a guest
Oct 16th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #~~~~~~~~~~~~~~~~~~~~~~~
  2. # Linux HW Scanner is a simple script to catch all Hardware Specifications from list of servers
  3. # Coded by : Sabry Saleh
  4. # License : GPL2
  5. #~~~~~~~~~~~~~~~~~~~~~~~
  6. #=-Notes-=
  7. # You have to install ruby + net-ssh gems
  8. # sudo gem install net-ssh
  9. #~~~~~~~~~~~~~~~~~~~~~~~
  10.  
  11. require 'net/ssh'
  12.  
  13. class LinxHWSpecs
  14. begin
  15. host = IO.readlines('done1.txt') # full path of servers' list
  16. port = 22 # SSH port
  17. user = 'root' # username
  18. pass = "p@ass20rd" # password
  19. i = 0
  20. cmd = ["sudo /sbin/ip addr | grep mtu | grep -v lo | awk '{print $2}'", # Interfaces
  21. "sudo /sbin/ip addr | grep -i inet | grep -v inet6 | awk '{print $2}' | grep -v 127.0.0.1", # IP-Address(v4)
  22. "sudo grep 'name' /proc/cpuinfo | tail -n 1 | cut -d ':' -f 2 | awk '{print $1,$2,$3}'", # CPU Info
  23. "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)
  24. "sudo free -m | grep Mem | awk '{ print $2 }'", # RAM Info (MB)
  25. "cat /etc/redhat-release", # Releas Version
  26. "hostname"] # Server Name
  27.  
  28. while i < host.length
  29. Net::SSH.start( host[i],user,:password => pass, :port=> port , :verbose=> :error ) do |ssh|
  30. puts "Server Name: #{ssh.exec!(cmd[6])}"
  31. puts "[+] Interfaces: \n#{ssh.exec!(cmd[0])}"
  32. puts "[+] IP-Address(v4): \n#{ssh.exec!(cmd[1])} \n"
  33. puts "[+] CPU Info: \n#{ssh.exec!(cmd[2])} \n"
  34. puts "[+] Disk Info(GB): \n#{ssh.exec!(cmd[3])} \n"
  35. puts "[+] RAM Info (MB): \n#{ssh.exec!(cmd[4])} \n"
  36. puts "[+] Releas Version: \n#{ssh.exec!(cmd[5])} \n"
  37. puts "[*]----------[ End Of #{ssh.exec!(cmd[6]).chomp} ]----------[*]
  38. "
  39. end # end of do
  40. i += 1
  41. end # end of while
  42.  
  43. rescue Exception => e
  44. puts "[!] Error @ #{host[i].chomp} : #{e}"
  45. end # end of begin
  46.  
  47. end # end of LinxHWSpecs
Add Comment
Please, Sign In to add comment