Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.81 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require 'rubygems'
  4. require 'cloudfiles'
  5.  
  6. unless ARGV.length == 2
  7.     puts "usage: #{$0} username api_key"
  8.     exit(1)
  9. end
  10.  
  11. cf = CloudFiles::Connection.new(:username => ARGV[0], :api_key => ARGV[1])
  12.  
  13. #Random Vars I need
  14. val2 = 0
  15. iterate=1
  16. mb = 1024 * 1024
  17. gb = mb * 1024
  18. marker = ""
  19. contcount = cf.containers.count
  20.  
  21.  
  22. if contcount > 10000
  23.     until iterate == contcount
  24.        
  25.             cf.containers(:marker => marker).each do |iter|
  26.                 val1 = cf.container(iter.bytes)
  27.                 val2 += val1
  28.  
  29.                 if (iterate % 10000) == 0
  30.                     marker = cf.containers(:marker=> marker)[9999]
  31.                 end
  32.                 iterate += 1
  33.             end
  34.         end
  35.  
  36. else
  37.     cf.containers.each do |iter|
  38.         val1 = cf.container(iter).bytes
  39.         val2 += val1
  40.     end
  41. end
  42.  
  43. puts "Cloud Files currently uses " + (val2 / gb).to_s + "GB(" + (val2 / mb).to_s + "MB)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement