Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require 'rubygems'
  4. require 'active_record'
  5. require 'pathname'
  6.  
  7.  
  8. # Config
  9.  
  10. server = 3 #chuck3
  11. webalizer = "/usr/local/bin/webalizer"
  12. logfile = "access_log"
  13.  
  14.  
  15. # Don't edit below..
  16.  
  17.  
  18. class Site < ActiveRecord::Base
  19. has_one :option
  20. end
  21.  
  22. class Option < Site
  23. set_table_name 'options'
  24. end
  25.  
  26. # Connect!
  27.  
  28. ActiveRecord::Base.establish_connection({
  29. :adapter => 'mysql',
  30. :database => 'hosting',
  31. :host => 'chuck.nsn.no',
  32. :username => 'chuck2',
  33. :password => 'hohoho',
  34. })
  35.  
  36.  
  37. sites = Site.find(:all, :include => :option, :conditions => ['options.access_log = "on" and server = ?',server])
  38.  
  39. sites.each do |s|
  40. logdir = s.homedir "/logs"
  41. statsdir = s.homedir "/web/stats"
  42.  
  43. #make sure logdir exists
  44. Pathname.new(logdir).mkpath
  45. Pathname.new(statsdir).mkpath
  46.  
  47. #webalize it!
  48. system("#{webalizer} -p -n '#{s.servername}' -C 0 -o #{statsdir} #{logdir}/#{logfile}")
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement