bin/riemann-health in riemann-tools-0.1.1 vs bin/riemann-health in riemann-tools-0.1.2
- old
+ new
@@ -13,10 +13,11 @@
opt :disk_critical, "Disk critical threshold (fraction of space used)", :default => 0.95
opt :load_warning, "Load warning threshold (load average / core)", :default => 3
opt :load_critical, "Load critical threshold (load average / core)", :default => 8
opt :memory_warning, "Memory warning threshold (fraction of RAM)", :default => 0.85
opt :memory_critical, "Memory critical threshold (fraction of RAM)", :default => 0.95
+ opt :checks, "A list of checks to run.", :type => :strings, :default => ['cpu', 'load', 'memory', 'disk']
def initialize
@limits = {
:cpu => {:critical => opts[:cpu_critical], :warning => opts[:cpu_warning]},
:disk => {:critical => opts[:disk_critical], :warning => opts[:disk_warning]},
@@ -43,13 +44,27 @@
@cpu = method :linux_cpu
@disk = method :disk
@load = method :linux_load
@memory = method :linux_memory
end
+
+ opts[:checks].each do |check|
+ case check
+ when "disk"
+ @disk_enabled = true
+ when "load"
+ @load_enabled = true
+ when "cpu"
+ @cpu_enabled = true
+ when "memory"
+ @memory_enabled = true
+ end
+ end
end
def alert(service, state, metric, description)
+ puts service
report(
:service => service.to_s,
:state => state.to_s,
:metric => metric.to_f,
:description => description
@@ -236,13 +251,21 @@
end
end
end
def tick
- @cpu.call
- @memory.call
- @disk.call
- @load.call
+ if @cpu_enabled
+ @cpu.call
+ end
+ if @memory_enabled
+ @memory.call
+ end
+ if @disk_enabled
+ @disk.call
+ end
+ if @load_enabled
+ @load.call
+ end
end
end
Riemann::Tools::Health.run