Skip to content

Instantly share code, notes, and snippets.

@thbounzer
Created June 1, 2012 13:20
Show Gist options
  • Save thbounzer/2852108 to your computer and use it in GitHub Desktop.
Save thbounzer/2852108 to your computer and use it in GitHub Desktop.
Get rf a2c modem state
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