Created
June 1, 2012 13:20
-
-
Save thbounzer/2852108 to your computer and use it in GitHub Desktop.
Get rf a2c modem state
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/https" | |
require "uri" | |
def check_rf(sitid) | |
magic_number = 1040187392+sitid.to_i | |
uri = URI.parse("https://sap2.astra2connect.com/tms/term/4-#{magic_number}/cgi-bin/modem_status") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
begin | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request.basic_auth("USER", "PWD") | |
response = http.request(request) | |
check_result = response.body | |
rescue Exception | |
puts "Something goes wrong, killing thread!" | |
Thread.current.exit | |
end | |
if /operational/.match(check_result).to_s == "operational" | |
puts sitid | |
end | |
end | |
threads =[] | |
puts "Passed #{ARGV.length} sitids" | |
items = ARGV.length | |
ARGV.each do|a| | |
threads << Thread.new{check_rf(a)} | |
end | |
threads.each do |t| | |
items = items - 1 | |
puts "There are #{items} threads running" | |
t.join | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment