Sha256: 6832e6a32c13d2730ad1c2b984c185767991cbb503aba87dfec632c7dcec05e0

Contents?: true

Size: 518 Bytes

Versions: 3

Compression:

Stored size: 518 Bytes

Contents

module Perus::Pinger
    class CPU < Command
        description 'Measures overall system CPU usage as a percentage on the
                     client.'
        metric!

        def run
            if `uname -s`.strip == 'Darwin'
                percent = 100 - `iostat -n 0`.split("\n")[2].split[2].to_i
            else
                percent = `grep 'cpu ' /proc/stat | awk '{print (1 - ($5 / ($2+$3+$4+$5+$6+$7+$8)))*100}'`
            end
            
            {cpu_all: percent.to_f}
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
perus-0.1.2 lib/perus/pinger/metrics/cpu.rb
perus-0.1.1 lib/perus/pinger/metrics/cpu.rb
perus-0.1.0 lib/perus/pinger/metrics/cpu.rb