Chapter 21. Processing Registration Data

Registration is a process where an agent on the server sends out a message on to the collective.registration.agent topic every registerinterval period. The default registration agent AgentList sends out a list of the MCollective agents installed and running in mcollectived.

In a default installation, every server publishes these registration messages, but no listener subscribes to them. I believe the original use was intended to simply keep the TCP connection alive in the presence of connection-tracking firewalls. Now that this is handled by the heartbeat support in STOMP 1.1+ protocol, registration … well, it has found its own reason to live.

Many people have started doing useful things with the registration agent. Let’s show you how to build your own agent and your own collector to grab that data and do something with it.

Registration Agent

If you were to look at the default registration agent in your libdir directory, you’d be amazed at how simple it is: 

$ cat /usr/libexec/mcollective/mcollective/registration/agentlist.rb
module MCollective
  module Registration
    # A registration plugin that simply sends in the list of agents we have
    class Agentlist<Base
      def body
        Agents.agentlist
      end
    end
  end
end

Yeah, it is simple. The module should subclass MCollective::Registration::Base. Define a body method which returns anything you want, and that data is sent out to the collective.registration.agent topic for you. You can make the data as complex ...

Get Learning MCollective now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.