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]]
28 request[:facts].split(',').map { |x| x.strip }.each do |fact|
30 response[fact] = value
32 reply[:values] = response
35 # Get the global stats for this mcollectied
36 action "daemon_stats" do
37 stats = PluginManager["global_stats"].to_hash
39 reply[:threads] = stats[:threads]
40 reply[:agents] = stats[:agents]
41 reply[:pid] = stats[:pid]
42 reply[:times] = stats[:times]
43 reply[:configfile] = Config.instance.configfile
44 reply[:version] = MCollective.version
46 reply.data.merge!(stats[:stats])
49 # Builds an inventory of all agents on teh machine
50 # including license, version and timeout information
51 action "agent_inventory" do
54 Agents.agentlist.sort.each do |target_agent|
55 agent = PluginManager["#{target_agent}_agent"]
56 actions = agent.methods.grep(/_agent/)
58 agent_data = {:agent => target_agent,
59 :license => "unknown",
60 :timeout => agent.timeout,
61 :description => "unknown",
62 :name => target_agent,
64 :version => "unknown",
67 agent_data.merge!(agent.meta)
69 reply[:agents] << agent_data
73 # Retrieves a single config property that is in effect
74 action "get_config_item" do
75 reply.fail! "Unknown config property #{request[:item]}" unless config.respond_to?(request[:item])
77 reply[:item] = request[:item]
78 reply[:value] = config.send(request[:item])
81 # Responds to PING requests with the local timestamp
83 reply[:pong] = Time.now.to_i
86 # Returns all configured collectives
87 action "collective_info" do
88 config = Config.instance
89 reply[:main_collective] = config.main_collective
90 reply[:collectives] = config.collectives
95 query = Data.ddl_transform_input(Data.ddl(request[:source]), request[:query].to_s)
100 data = Data[ request[:source] ].lookup(query)
102 data.keys.each do |key|
103 reply[key] = data[key]