O'Reilly logo

Learning MCollective by Jo Rhett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. Registration

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 nothing 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 or as simple as meets your needs. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required