Sha256: 20f5a9ec6cf3e4b19971c6abd5fc85d2c3d6a8aec785033a426a0b423de8e537

Contents?: true

Size: 1.1 KB

Versions: 26

Compression:

Stored size: 1.1 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 = {}

        RestFtpDaemon::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

26 entries across 26 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.435.2 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.435.1 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.435.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.434.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.433.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.432.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.430.1 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.430.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.424.3 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.424.2 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.424.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.423.3 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.423.2 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.423.1 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.423.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.422.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.421.1 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.421.0 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.420.2 lib/rest-ftp-daemon/metrics.rb
rest-ftp-daemon-0.420.1 lib/rest-ftp-daemon/metrics.rb