Skip to content

Instantly share code, notes, and snippets.

/test

Created December 23, 2009 15:32
Show Gist options
  • Save anonymous/262577 to your computer and use it in GitHub Desktop.
Save anonymous/262577 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'net/http'
Net::HTTP.start('op0') {|http|
req = Net::HTTP::Get.new('/nagios/cgi-bin/extinfo.cgi?type=5&hostgroup=websites')
req.basic_auth 'USER', 'BLANK'
response = http.request(req)
print response.body
cookie = response.response['set-cookie']
path = '/nagios/cgi-bin/cmd.cgi'
data = 'btnSubmit=Commit&cmd_mod=2&cmd_typ=66&hostgroup=websites'
headers = {
'Cookie' => cookie,
'Referer' => '/nagios/cgi-bin/extinfo.cgi?type=5&hostgroup=websites',
'Content-Type' => 'application/x-www-form-urlencoded'
}
resp, data = http.post(path, data, headers)
puts 'Code = ' + resp.code
puts 'Message = ' + resp.message
resp.each {|key, val| puts key + ' = ' + val}
puts data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment