class Statful::Parser

Public Class Methods

parse(output) click to toggle source

Parses the check_cpu output and returns the total percentage of cpu in use

# File lib/parsers/check_cpu.rb, line 5
def self.parse(output)
  # Output example:
  # CheckCPU TOTAL OK: total=19.19 user=17.17 nice=0.0 system=1.01 idle=80.81 iowait=0.0 irq=0.0 softirq=1.01 steal=0.0 guest=0.0

  if !output.nil?
    output.split(' ')[3].split('=')[1]
  else
    puts 'Check output is nil'
    exit
  end
end