Skip to content

Instantly share code, notes, and snippets.

@ripienaar
Created March 8, 2011 15:26
Show Gist options
  • Save ripienaar/860404 to your computer and use it in GitHub Desktop.
Save ripienaar/860404 to your computer and use it in GitHub Desktop.
script to test the filemgr agent standalone without requiring mcollective to run
#!/usr/bin/ruby
require 'mcollective'
require 'pp'
configfile = "server.cfg"
agent = "filemgr"
request = {:action => "status",
:data => {:file => "/tmp"}}
classname = "MCollective::Agent::#{agent.capitalize}"
class NoopConnector
def method_missing(*args)
MCollective::Log.debug("connector #{args.pretty_inspect}")
true
end
end
# stub the connector with a noop one
MCollective::PluginManager << {:type => "connector_plugin", :class => "NoopConnector"}
connection = MCollective::PluginManager["connector_plugin"]
config = MCollective::Config.instance
config.loadconfig(configfile) unless config.configured
MCollective::PluginManager.loadclass(classname)
MCollective::PluginManager << {:type => "#{agent}_agent", :class => classname}
pp MCollective::PluginManager["#{agent}_agent"].handlemsg({:body => request}, connection)
debug 2011/03/08 15:26:21: ddl.rb:56:in `findddlfile' Found filemgr ddl at /usr/libexec/mcollective/mcollective/agent/filemgr.ddl
debug 2011/03/08 15:26:21: pluginmanager.rb:73:in `[]' Returning plugin filemgr_agent with class MCollective::Agent::Filemgr
debug 2011/03/08 15:26:21: filemgr.rb:63:in `status' Asked for status of '/tmp' - it is present
{:statusmsg=>"OK",
:data=>
{:ctime=>Tue Mar 08 15:07:57 +0000 2011,
:type=>"directory",
:present=>1,
:uid=>0,
:mtime_seconds=>1299596877,
:gid=>0,
:ctime_seconds=>1299596877,
:atime_seconds=>1299529385,
:atime=>Mon Mar 07 20:23:05 +0000 2011,
:size=>4096,
:output=>"present",
:name=>"/tmp",
:md5=>0,
:mtime=>Tue Mar 08 15:07:57 +0000 2011,
:mode=>"41777"},
:statuscode=>0}
libdir = /usr/libexec/mcollective
loglevel = debug
logger_type = console
@ripienaar
Copy link
Author

How to run an mcollective agent without the middleware, daemons etc, little thing to help with development and debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment