# File lib/new_relic/agent/samplers/cpu_sampler.rb, line 50 def poll now = Time.now t = Process.times if @last_time elapsed = now - @last_time return if elapsed < 1 # Causing some kind of math underflow usertime = t.utime - @last_utime systemtime = t.stime - @last_stime record_systemtime(systemtime) if systemtime >= 0 record_usertime(usertime) if usertime >= 0 # Calculate the true utilization by taking cpu times and dividing by # elapsed time X processor_count. record_user_util(usertime / (elapsed * @processor_count)) record_system_util(systemtime / (elapsed * @processor_count)) end @last_utime = t.utime @last_stime = t.stime @last_time = now end