Here's a script that gets the file sizes for a set of files and sends the data to stathat:
#!/usr/bin/env ruby

require 'rubygems'
require 'stathat'

FILES = [["/opt/local/var/db/buckets.tct", "somekeyforstat1"],
        ["/opt/local/var/db/stats.tct", "somekeyforstat2"],
        ["/opt/local/var/db/users.tct", "somekeyforstat3"]]
        
FILES.each do |elts|
        StatHat::API.post_value(elts[1], 'youruserkey', File.size(elts[0]))
end
Put it in cron to run every 5 minutes.

david12

It would be nice if the awesome, stathat, recognizes file sizes so it could be formatted in b/kb/mb/gb.

posted 2014-09-21 11:17:38