diff --git a/chef/cookbooks/common/files/default/backupcron.txt b/chef/cookbooks/common/files/default/backupcron.txt index 65c1a3db4..d4a6be5de 100644 --- a/chef/cookbooks/common/files/default/backupcron.txt +++ b/chef/cookbooks/common/files/default/backupcron.txt @@ -1,2 +1,5 @@ 42 * * * * cd /usr/local/app/diaspora && exec /usr/local/bin/ruby /usr/local/bin/bundle exec rake --trace backup:mongo &> /usr/local/app/diaspora/log/rake_mongo.log 42 15 * * * cd /usr/local/app/diaspora && exec /usr/local/bin/ruby /usr/local/bin/bundle exec rake --trace backup:photos &> /usr/local/app/diaspora/log/rake_photos.log +#statistics +42 15 * * * cd /usr/local/app/diaspora && exec /usr/local/bin/ruby /usr/local/bin/bundle exec rake --trace statistics:users_splunk &> /usr/local/app/diaspora/log/stats.log +42 15 * * * cd /usr/local/app/diaspora && exec /usr/local/bin/ruby /usr/local/bin/bundle exec rake --trace statistics:content_splunk &> /usr/local/app/diaspora/log/stats.log diff --git a/lib/tasks/statistics.rake b/lib/tasks/statistics.rake index 11beca982..ce969862d 100644 --- a/lib/tasks/statistics.rake +++ b/lib/tasks/statistics.rake @@ -10,6 +10,29 @@ namespace :statistics do puts "Users signed in in last 7d: %i" % User.where(:current_sign_in_at.gt => Time.now - 7.days).count end + task :users_splunk => :environment do + puts "event=statistic, type=users, count=#{User.count}, "+ + "incomplete=#{User.where(:getting_started => true, :sign_in_count.gt => 0).count}, " + + "last_1d=#{User.where(:current_sign_in_at.gt => Time.now - 1.days).count}, "+ + "last_7d=#{User.where(:current_sign_in_at.gt => Time.now - 7.days).count}, " + + "notification_off=#{User.where(:disable_email=>true).count}, "+ + "notification_off_%=#{User.where(:disable_email=>true).count.to_f/User.count}, "+ + "no_invites=#{User.where(:invites => 0).count} " + + + puts "event=statistic, type=users, last_7d_%=#{User.where(:current_sign_in_at.gt => Time.now - 7.days).count.to_f/User.count}, " + + "last_7d_and_notifications_off_%=#{User.where(:current_sign_in_at.gt => Time.now - 7.days, :disable_email => true).count.to_f/User.where(:disable_email=>true).count}, " + + "last_7d_and_no_invites_%=#{User.where(:current_sign_in_at.gt => Time.now - 7.days, :invites => 0).count.to_f/User.where(:invites => 0).count}" + + + + puts "event=statistic, type=invitations, count=#{Invitation.count}" + puts "event=statistic, type=contacts, active_count=#{Contact.where(:pending => false).count}" + puts "event=statistic, type=contacts, pending_count=#{Contact.where(:pending => true).count}" + + puts "event=statistic, type=aspect, count=#{ Aspect.count }" + end + desc 'on content: posts, photos, status messages, comments' task :content => :environment do puts "Services: %i Facebook, %i Twitter" % [Services::Facebook.count, Services::Twitter.count] @@ -18,6 +41,13 @@ namespace :statistics do puts "Comments: %i" % Comment.count puts "Photos: %i" % Photo.count end + + task :content_splunk => :environment do + puts "event=statistic, type=posts, count=#{Post.count}, public_count=#{Post.where(:public => true).count}, public_% =#{Post.where(:public => true).count.to_f/Post.count}" + + "last_day = #{Post.where(:created_at.gt => Time.now - 1.days).count}, last_day_public_count=#{Post.where(:created_at.gt => Time.now - 1.days, :public => true).count}, "+ + "last_day_public_% = #{Post.where(:created_at.gt => Time.now - 1.days, :public => true).count.to_f/Post.where(:created_at.gt => Time.now - 1.days).count}" + end + task :genders => :environment do genders = Person.collection.group(['profile.gender'], {}, {:count => 0}, 'function(o,p) { p.count++; }', true ) genders.sort!{|a,b| a['profile.gender'].to_s <=> b['profile.gender'].to_s}