3 class Rpcutil<RPC::Agent
4 # Basic system inventory, same as the basic discovery agent
6 reply[:agents] = Agents.agentlist
7 reply[:facts] = PluginManager["facts_plugin"].get_facts
8 reply[:version] = MCollective.version
10 reply[:main_collective] = config.main_collective
11 reply[:collectives] = config.collectives
12 reply[:data_plugins] = PluginManager.grep(/_data$/)
14 cfile = Config.instance.classesfile
16 reply[:classes] = File.readlines(cfile).map {|i| i.chomp}
20 # Retrieve a single fact from the node
22 reply[:fact] = request[:fact]
23 reply[:value] = Facts[request[:fact]]
26 # Get the global stats for this mcollectied
27 action "daemon_stats" do
28 stats = PluginManager["global_stats"].to_hash
30 reply[:threads] = stats[:threads]
31 reply[:agents] = stats[:agents]
32 reply[:pid] = stats[:pid]
33 reply[:times] = stats[:times]
34 reply[:configfile] = Config.instance.configfile
35 reply[:version] = MCollective.version
37 reply.data.merge!(stats[:stats])
40 # Builds an inventory of all agents on teh machine
41 # including license, version and timeout information
42 action "agent_inventory" do
45 Agents.agentlist.sort.each do |target_agent|
46 agent = PluginManager["#{target_agent}_agent"]
47 actions = agent.methods.grep(/_agent/)
49 agent_data = {:agent => target_agent,
50 :license => "unknown",
51 :timeout => agent.timeout,
52 :description => "unknown",
53 :name => target_agent,
55 :version => "unknown",
58 agent_data.merge!(agent.meta)
60 reply[:agents] << agent_data
64 # Retrieves a single config property that is in effect
65 action "get_config_item" do
66 reply.fail! "Unknown config property #{request[:item]}" unless config.respond_to?(request[:item])
68 reply[:item] = request[:item]
69 reply[:value] = config.send(request[:item])
72 # Responds to PING requests with the local timestamp
74 reply[:pong] = Time.now.to_i
77 # Returns all configured collectives
78 action "collective_info" do
79 config = Config.instance
80 reply[:main_collective] = config.main_collective
81 reply[:collectives] = config.collectives
86 query = Data.ddl_transform_input(Data.ddl(request[:source]), request[:query].to_s)
91 data = Data[ request[:source] ].lookup(query)
93 data.keys.each do |key|
94 reply[key] = data[key]