Sha256: 4cbd7aaca1df400393423e3383b7f67183eb187603db6a2add023e5e8b345e69

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require "vmstat"

module AppPerfAgent
  module Plugin
    module System
      class Cpu < AppPerfAgent::Plugin::Base
        def call
          cpus = Vmstat.snapshot.cpus
          cpus.flat_map {|cpu|
            [
              [
                AppPerfAgent::Types::CPU,
                "system.cpu.idle",
                "CPU ##{cpu.num} (Idle)",
                cpu.idle
              ],
              [
                AppPerfAgent::Types::CPU,
                "system.cpu.nice",
                "CPU ##{cpu.num} (Nice)",
                cpu.nice
              ],
              [
                AppPerfAgent::Types::CPU,
                "system.cpu.system",
                "CPU ##{cpu.num} (System)",
                cpu.system
              ],
              [
                AppPerfAgent::Types::CPU,
                "system.cpu.user",
                "CPU ##{cpu.num} (User)",
                cpu.user
              ]
            ]
          }
        end
      end
    end
  end
end

AppPerfAgent.logger.info "Loading CPU monitoring."

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
app_perf_agent-0.0.2 lib/app_perf_agent/plugin/system/cpu.rb