Module: StatMon::Listener
- Included in:
- StatMon
- Defined in:
- lib/stat_mon/listener.rb
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
4 5 6 |
# File 'lib/stat_mon/listener.rb', line 4 def init @monitors = Hash.new end |
#monitor {|task| ... } ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/stat_mon/listener.rb', line 12 def monitor(&block) task = Task.new yield(task) raise DuplicateMonitorName, "Duplicate monitor name" if monitors.has_key? task.name monitors[task.name] = task end |
#monitors ⇒ Object
8 9 10 |
# File 'lib/stat_mon/listener.rb', line 8 def monitors @monitors end |
#start ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stat_mon/listener.rb', line 20 def start EventMachine.run do monitors.each do |name, task| EventMachine.add_periodic_timer(task.interval) do EventMachine.system( task.process ) do |output, status| task.log output end end end end end |