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
 
41b3979f
 			@cpu_load = 0.00
fbb14c29
 			@options = {notify_threshold: @cpu_count*0.90}
7175b248
 		end
 
fbb14c29
 		def load_options(options)
d7f5c0aa
 			@options.merge!(options)
01ff794e
 		end
 
 		def results
41b3979f
 			@cpu_load = File.read("/proc/loadavg").split(" ").first.to_f
01ff794e
 		end
 
 		def notify?
176325b1
 			@cpu_load >= @options[:notify_threshold].to_f
01ff794e
 		end
 
eb09be77
 		def graph_labels
 			{
 				y_axis: @y_axis,
 				graph_name: "#@graph_name (CPUs: #@cpu_count)"
 			}
01ff794e
 		end
def91ab1
 	end
 end