lib/rubysermon/mod/cpu.rb
def91ab1
 module Rubysermon
 	class Cpu < ModTemplate
 
7175b248
 		def initialize
01ff794e
 			@y_axis = "CPU Load"
 			@graph_name = "CPU Load In Time"
7175b248
 
01ff794e
 			@cpu_count = File.readlines("/proc/stat").select { |line|
 				line =~ /^cpu[\d]/
 			}.length
4bf9b346
 
fbb14c29
 			@cpu_load = 0
 			@options = {notify_threshold: @cpu_count*0.90}
7175b248
 		end
 
fbb14c29
 		def load_options(options)
d7f5c0aa
 			@options.merge!(options)
01ff794e
 		end
 
 		def results
fbb14c29
 			@cpu_load = File.read("/proc/loadavg").split(" ").first.to_s
01ff794e
 		end
 
 		def notify?
b00036cc
 			@cpu_load >= @options[:notify_threshold].to_i
01ff794e
 		end
 
 		def y_axis_name
 			@y_axis
 		end
 
 		def graph_name
 			"#@graph_name (CPUs: #@cpu_count)"
 		end
def91ab1
 	end
 end