lib/riemann/babbler/plugins/memory.rb in riemann-babbler-0.5.3 vs lib/riemann/babbler/plugins/memory.rb in riemann-babbler-0.5.4
- old
+ new
@@ -12,10 +12,10 @@
total = m['MemTotal'].to_i
used = total - free
free_bc = free + buffers + cached
fraction = 1 - (free.to_f / total)
- swap_fraction = (m['SwapTotal'] - m['SwapFree']).to_f/m['SwapTotal']
+ swap_fraction = m['SwapTotal'] == 0 ? 0 : 1 - m['SwapFree'].to_f/m['SwapTotal']
desc = "usage\n\n#{shell('ps -eo pmem,pid,cmd | sort -nrb -k1 | head -10').chomp}"
[
{ :service => plugin.service + " % free", :metric => fraction },