Sha256: aa241817a8c9edc1b9ab77bfe6a7f4931c3528b174ca7347561a1ed0cd4ad232

Contents?: true

Size: 519 Bytes

Versions: 41

Compression:

Stored size: 519 Bytes

Contents

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

        def run
            if darwin?
                percent = 100 - shell('iostat dxxvdfs -n 0').split("\n")[2].split[2].to_i
            else
                percent = shell("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

41 entries across 41 versions & 1 rubygems

Version Path
perus-1.0.7 lib/perus/pinger/metrics/cpu.rb
perus-1.0.6 lib/perus/pinger/metrics/cpu.rb
perus-1.0.5 lib/perus/pinger/metrics/cpu.rb
perus-1.0.4 lib/perus/pinger/metrics/cpu.rb
perus-1.0.3 lib/perus/pinger/metrics/cpu.rb
perus-1.0.2 lib/perus/pinger/metrics/cpu.rb
perus-1.0.1 lib/perus/pinger/metrics/cpu.rb
perus-1.0.0 lib/perus/pinger/metrics/cpu.rb
perus-0.1.35 lib/perus/pinger/metrics/cpu.rb
perus-0.1.34 lib/perus/pinger/metrics/cpu.rb
perus-0.1.33 lib/perus/pinger/metrics/cpu.rb
perus-0.1.32 lib/perus/pinger/metrics/cpu.rb
perus-0.1.31 lib/perus/pinger/metrics/cpu.rb
perus-0.1.30 lib/perus/pinger/metrics/cpu.rb
perus-0.1.29 lib/perus/pinger/metrics/cpu.rb
perus-0.1.28 lib/perus/pinger/metrics/cpu.rb
perus-0.1.27 lib/perus/pinger/metrics/cpu.rb
perus-0.1.26 lib/perus/pinger/metrics/cpu.rb
perus-0.1.25 lib/perus/pinger/metrics/cpu.rb
perus-0.1.24 lib/perus/pinger/metrics/cpu.rb