Skip to content

Instantly share code, notes, and snippets.

@johnpmitsch
Last active October 16, 2019 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpmitsch/ec777c75cca3b1939c243f32a57e38bf to your computer and use it in GitHub Desktop.
Save johnpmitsch/ec777c75cca3b1939c243f32a57e38bf to your computer and use it in GitHub Desktop.
hammer concurrent requests on centos7-hammer-devel box
#!/usr/bin/env ruby
# This will send concurrent hammer requests from a centos7-hammer-devel box. Update the commands below to alter the request
require 'net/http'
hammer="BUNDLE_GEMFILE=~/hammer-cli-foreman/Gemfile bundle exec hammer"
# create base command
base_command = "repository info "
# create an array of flags
command_flags = ['--id 1','--id 2','--id 3']
# Create an array to keep track of threads.
threads = []
command_flags.each_with_index do |flag, i|
# spawn a new thread for each url
threads << Thread.new do
cmd = `#{hammer} #{base_command} #{flag}`
puts "\nRequest #{i+1} Complete: \n#{cmd}\n"
end
end
# wait for threads to finish before ending program.
threads.each { |t| t.join }
puts "All Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment