Skip to content
Browse files

Allow printing monitor-cpu's internal state.

  • Loading branch information...
1 parent 38f185a commit cb04a9ad86b58cadd5b405d75eb3a0a0de0562f4 @FooBarWidget FooBarWidget committed
Showing with 8 additions and 2 deletions.
  1. +8 −2 monitor-cpu
View
10 monitor-cpu
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/shared')
+require 'pp'
class MonitorCpu
def initialize(interval, total_threshold, per_core_threshold)
@@ -40,7 +41,7 @@ class MonitorCpu
def measurement_points
return @cpu_usages.size
end
-
+
def average(cpu_id = :all)
total = 0
@cpu_usages.each do |cpu_usage|
@@ -235,7 +236,12 @@ else
config(:to)
config(:subject)
begin
- MonitorCpu.new(config(:interval), config(:total_threshold), config(:per_core_threshold)).start
+ monitor = MonitorCpu.new(config(:interval), config(:total_threshold), config(:per_core_threshold))
+ trap 'QUIT' do
+ pp monitor
+ STDOUT.flush
+ end
+ monitor.start
rescue Interrupt
# Do nothing.
rescue SignalException => e

0 comments on commit cb04a9a

Please sign in to comment.
Something went wrong with that request. Please try again.