Created
April 15, 2011 08:00
-
-
Save dolzenko/921342 to your computer and use it in GitHub Desktop.
Show stats for all of your Heroku apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'heroku' | |
require "heroku/command/base" | |
user, pass = File.read("#{ENV['HOME']}/.heroku/credentials").split(/\r?\n/) | |
HEROKU = Heroku::Client.new(user, pass) | |
class Heroku::Client | |
def list_collaborators(*) # SKIP - QUICKER | |
[] | |
end | |
def installed_addons(*) # SKIP - QUICKER | |
[] | |
end | |
end | |
class App | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def info | |
@info ||= HEROKU.info(name) | |
end | |
def formatted | |
tokens = info.values_at(:dynos, :workers) + | |
info.values_at(:repo_size, :slug_size, :database_size).map {|i| (i.to_i / 1048576.0).round.to_s + 'M' } + | |
info.values_at(:cron_finished_at, :cron_next_run).map {|i| (i ? Time.parse(i).utc.strftime('%d %b %H:%M') : '-').ljust(14) } | |
tokens.map {|i| i.to_s.ljust(5) } | |
end | |
def to_s | |
"#{name.ljust(20)} | #{formatted.join(' | ')}" | |
end | |
end | |
puts " | Dynos | Work. | Repo | Slug | Data | Last Cron | Next Cron" | |
Heroku::Command::Base.new.send(:git_remotes).values.sort.each do |name, owner| | |
puts App.new(name).to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment