How do I write an mco agent to get the correct system time?

asked 2015-01-20 19:13:18 -0600

bobmacks gravatar image

updated 2015-01-21 16:04:16 -0600

Hi Fellow Puppeteers,

The running pe-mcollective daemon on my node appears be caching the results of and from my mco agent plugin. Running mco from my master I always get the same date and time results. The time and date only seem to change after I restart pe-mcollective daemon on the node.

module MCollective
  module Agent
    class Datetest<RPC::Agent
      require 'date'
      systime = `/bin/date '+%Y-%m-%d %H:%M:%S'`
      rbtime =
      rbtoday =
      action 'showdate' do
          reply[:status] = 0
          reply[:out] = "++ today: #{rbtoday}\n++ time: #{rbtime}\n++ systime: #{systime}"
      end       # of download
    end # of Datetest
  end   # of Agent
end     # of MCollective

On the client side I just call the agent plugin and carry out a little formatting... something like...

app = rpcclient('datetest')
action = ARGV.shift
results = app.send(action)
results.each do |result|
  printf("%s: status: %d\n", result[:sender], result[:data][:status]) 
  out_flat = result[:data][:out].split("\n").select { |line| 
    line[/\+\+.*/] }.join("\n  ")
  printf("  %s\n", out_flat)

Then when I run 'mco datetest ...' I get...

peadmin@master:~$ mco datetest showdate -v -I mynode

 * [ ============================================================> ] 1 / 1

mynode: status: 0
  ++ today: 2015-01-21
  ++ time: 2015-01-21 11:36:13 +1100
  ++ systime: 2015-01-21 11:36:13

Running mco again a few seconds or minutes later returns exactly the same results for date, time and systime. The results only change after restarting pe-mcollective on my node.

Is there any way I can get the correct current time and date via an mco plugin?

  • Puppet v3.2.4 (Puppet Enterprise 3.0.1)
  • The Marionette Collective version 2.2.4
  • ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]

Cheers, Bobby

edit retag flag offensive close merge delete