Top Level Namespace

Defined Under Namespace

Modules: Zabbix Classes: String

Instance Method Summary collapse

Instance Method Details

#fuzz(t) ⇒ Object

Miscellaneous functions that aren’t technically part of Zabbix, but are used in zabbixmon



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/zmonitor/misc.rb', line 5

def fuzz(t)
  t = 0 if t < 0 # we don't need negative fuzzy times.
  d = t / 86400
  h = t % 86400 / 3600
  m = t % 3600  / 60
  s = t % 60
  fuzzy = ['d', 'h', 'm', 's'].map do |unit|
    amt = eval(unit)
    "%3d#{unit}" % amt
  end.join
  return "#{fuzzy}"[8..-1] if h == 0
  return "#{fuzzy}"[4..-5] if d == 0
  return "#{fuzzy}"[0..-9]
end