Sha256: dfe2d77b48ce4f003d0ea2d8d5303d35cf454f3d0b62b1e216ef1c1c5be63700

Contents?: true

Size: 1.08 KB

Versions: 21

Compression:

Stored size: 1.08 KB

Contents

module RestFtpDaemon
  class Metrics

    def self.sample
      # Prepare external deps
      mem = GetProcessMem.new

      # Build final value
      return  {
        system: {
          uptime:           (Time.now - Conf.app_started).round(1),
          memory:           mem.bytes.to_i,
          threads:          Thread.list.count,
          },
        jobs_by_status:     RestFtpDaemon::JobQueue.instance.jobs_by_status,
        rate_by_pool:       RestFtpDaemon::JobQueue.instance.rate_by(:pool),
        rate_by_targethost: RestFtpDaemon::JobQueue.instance.rate_by(:targethost),
        queued_by_pool:     RestFtpDaemon::JobQueue.instance.queued_by_pool,
        workers_by_status:  self.workers_count_by_status,
        }
    end

    private

      # Collect: workers by status
      def self.workers_count_by_status
        # Init
        counts = {}

        WorkerPool.instance.worker_variables.group_by do |wid, vars|
          vars[:status]
        end.each do |status, workers|
          counts[status] = workers.count
        end

        # Return count
        counts
      end

  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rest-ftp-daemon-1.1.1 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.1.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.15 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.14 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.13 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.12 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.11 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.10 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.9 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.8 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.7 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.6 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.5 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.4 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.3 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.2 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-1.0.1 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.502.2 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.502.1 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.502.0 lib/rest-ftp-daemon/metrics.rb