Sha256: 3f5df0e8a916a1fa0c110675d79a90be0456c84160c7cfc5bebbea9060c4bdd4

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

#!/usr/bin/env ruby
#
# Script to print out when puppet ran successfully last
# AJ Christensen <aj@junglist.gen.nz>
#

require 'puppet'
require 'puppet/defaults'
require 'yaml'

Puppet[:config] = "/etc/puppet/puppet.conf"
Puppet.parse_config

print "puppetlast\n"

nodes = {}

yfdir = Puppet.settings.value(:vardir) + "/yaml/facts"

if yfdir
   begin
      Dir.chdir(yfdir) do
         Dir.glob("*.yaml").each do |yaml|
            data = YAML.load_file(yaml)
            t = Time.now
            age = t - data.version
            nodes[data.name] = age.to_i
         end
      end

      nodes.sort.each do |node,age|
         minutes = age / 60 + 0.5
         print minutes.floor.to_s + ' minutes ago: ' + node + "\n"
      end

   rescue
      print 'error: ' + $! + "\n"
   end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-0.24.5 ext/puppetlast