August 2014
Intermediate to advanced
284 pages
5h 24m
English
One of the features that makes MCollective truly unique is the ability to send requests from one client and to process the responses with a different client or listener, as shown in Figure 22-1.
The first thing we’ll do here is to create a listener. What I’ll introduce to you here is a working listener from which you can debug any problem. You can also copy it and add new functionality. I put my listeners in the $libdir directory just like every other plugin, but that’s not required:
$ cat /usr/libexec/mcollective/mcollective/listener/debugger.rb # Parse options, load config, and start an MCollective client. require 'mcollective' optparser = MCollective::Optionparser.new options = optparser.parse config = MCollective::Config.instance config.loadconfig(options[:config]) MCollective::PluginManager["security_plugin"].initiated_by = :client connector = MCollective::PluginManager['connector_plugin'] connector.connect # Get pretty-print and the Log object require 'pp' Log = MCollective::Log # Get a reply queue name from command line, default to "debugger" replyqueue = ARGV[0] || 'debugger' queuename = '/queue/mcollective.reply.' + replyqueue # Subscribe to the queue connector.connection.subscribe( queuename, {}, "$$".to_i ) # consume all the items in the queue... loop ...