Guest User

Untitled

a guest
Sep 25th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. ⚡ cat mcollective-many-client
  2. #!/usr/bin/env ruby
  3. require 'rubygems'
  4. gem 'stomp', '=1.2.11'
  5. require 'mcollective'
  6. include MCollective::RPC
  7.  
  8. c = rpcclient("rpcutil")
  9.  
  10. server_count = ARGV[0] || "1"
  11. server_count = server_count.to_i
  12.  
  13. reply_to = "/queue/global.reply.spammy_#{$$}"
  14.  
  15. connection = MCollective::PluginManager["connector_plugin"].connection
  16.  
  17. connection.subscribe(reply_to)
  18.  
  19. body = "I know a song that'll get on your nerves\n" * 13 # about 500 bytes, same as a rpc rpcutil ping
  20.  
  21. 1000.times do |i|
  22. expires = ((Time.now.to_i + 60) * 1000).to_s
  23. 1000.times do |j|
  24. server = j % server_count
  25. identity = "#{i}-#{j}-#{server}"
  26. connection.publish('/queue/tive.nodes', body, {
  27. "mc_traceme" => identity,
  28. "mc_identity" => "mini-server#{server}.example.com",
  29. "reply-to" => reply_to,
  30. # "expires" => expires,
  31. })
  32. puts "#{Time.now.to_f} sent #{identity}"
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment