Issue #9846 has been updated by Tom Scofield.

Here is some code I worked out.  I'm not sure the best way to integrate it into 
the existing store.rb file.  Also, is this the right way to pull parameters 
from config file?  In the test I did I couldn't get those parameters pulled in.


    reportdays=Puppet[:reportstoredays]
    reportcount=Puppet[:reportstorecount]

    reportdays=reportdays.to_i
    reportcount=reportcount.to_i

    if defined?(reportdays)
      rlast= Time.now.gmtime - (reportdays * 86400)
      rdate = %w{year month day hour min}.collect do |method|
        # Make sure we're at least two digits everywhere
        "%02d" % rlast.send(method).to_s
      end.join("")
    end
    rcount=0

    Dir.entries(dir).sort.reverse.each do |file|
      next if ['.','..'].include?(file)
      rcount+=1
      if defined?(reportcount) && reportcount > 0 && rcount > reportcount
        #puts "#{file} should be deleted, to many files #{rcount}"
        file = File.join(dir, file)
        File.unlink(file) if File.file?(file)
        next
      end

    if defined?(rdate) && reportdays > 0 && file.split(".").first < rdate
      #puts "#{file} should be deleted, to old #{rdate}"
      file = File.join(dir, file)
      File.unlink(file) if File.file?(file)
      next
    end
    #puts file
    end
    
----------------------------------------
Feature #9846: Add option to store report to limit the number of reports 
retained
https://projects.puppetlabs.com/issues/9846

Author: Tom Scofield
Status: Accepted
Priority: Normal
Assignee: Tom Scofield
Category: reports
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


The number of reports in the store report continually grows. An ooption should 
be added to remove old reports.  It could be count or date based and the 
parameter could be configured in puppet.conf

An example would be
storecount=10000
or 
storedays=30

When the reports grow beyond these values the store.rb would remove them from 
the filesystem.  The would eliminate the need to have an outside process clean 
up this data.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to