Guest User

Untitled

a guest
Jan 3rd, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #!/usr/local/bin/ruby
  2.  
  3. require 'net/ssh'
  4.  
  5. def usage
  6. print("\n\nUsage: ./owner_of_tn.rb <telephone number>\n\n")
  7. exit
  8. end
  9.  
  10. usage if ARGV[0].nil?
  11.  
  12. def display
  13. puts "\n ** Checking the feature servers now **\n\n"
  14. end
  15.  
  16. def login_and_query(number)
  17.  
  18. @username = 'aguevara'
  19. @password = 'LIMA peru 2'
  20.  
  21. @ngrep = {}
  22. @feature_servers = ['fsa.monmouth.com','cm-mg0.monmouth.com','cm-mg1.monmouth.com','pl-fsa.monmouth.com']
  23.  
  24. @feature_servers.each do |s|
  25. begin
  26. Net::SSH.start(s, @username, :password => @password ) do |ssh|
  27. @ngrep[ssh.exec!("uname -n")] = ssh.exec!("egrep -l #{number} /etc/asterisk/customer/*")
  28. .to_s.scan(/\d{5}\./).uniq
  29. end
  30. rescue => e
  31. puts "Error: #{e}"
  32. end
  33. end
  34.  
  35. @ngrep.each do |key,val|
  36. server = key.upcase.gsub(/\n/,'')
  37. account = val.to_s.gsub(/\./,'')
  38. val.empty? || val.nil? ?
  39. (puts " => #{number} not found on the [ #{server} ] feature server") :
  40. (puts " -> Found #{number} on the [ #{server} ] feature sever for account(s) #{account}")
  41. end
  42.  
  43. end
  44.  
  45. display
  46. login_and_query(ARGV[0])
Add Comment
Please, Sign In to add comment