Sha256: a6b05cd5b5a98d5b0fe38c5476d45356dcf8620709abbbda19058fe9d65e489c

Contents?: true

Size: 1.22 KB

Versions: 24

Compression:

Stored size: 1.22 KB

Contents

class Admin::SkynetController < AdminController

  def index
    begin
      start_time = Time.now
      setup
      if params[:skynet_message_queue]
        Skynet.configure(:MYSQL_MESSAGE_QUEUE_TABLE => params[:skynet_message_queue]) do
          @stats = @mq.stats
        end
      else
        @stats = @mq.stats
      end
      @stats.merge!(Skynet::Manager.stats_for_hosts)
      @stats[:hosts] = @stats[:servers].size
      @stats[:processed_time] = Time.now - start_time
    rescue Exception => e
      logger.error "ERROR #{e.inspect} #{e.backtrace.join("\n")}"      
    end
  end
  
  # plain text page that will be used by monitoring scripts
  def status
    begin
      setup
      stats = @mq.stats
      stats[:servers] = stats[:servers].keys.join(",")
      stats.each { |k,v| stats[k.to_s] = stats.delete(k) }
      text  = stats.keys.sort.collect{ |k| "#{k}:#{stats[k]}" }.join("\n") + "\n"
      render :text => text, :content_type => 'text/plain'
    rescue Exception => e
      render :text => "skynet is down\n", :content_type => 'text/plain'
    end
  end  
  
  private
  
  def setup
    @mq  ||= Skynet::MessageQueue.new(Skynet::CONFIG[:MESSAGE_QUEUE_ADAPTER])
    @last_updated = Time.now.strftime('%r')
  end
  
end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
brendan-skynet-0.9.3.1 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.3.2 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.3.3 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.3.5 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.3.6 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.3.7 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.3.8 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.303 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.304 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.305 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.31 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.310 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.311 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.312 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.313 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.314 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.315 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.316 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.317 extras/rails/controllers/skynet_controller.rb
brendan-skynet-0.9.318 extras/rails/controllers/skynet_controller.rb