Module: Heartbeat
- Defined in:
- lib/tools/heartbeat.rb
Overview
A heartbeat monitor
The heartbeat monitor watches various machine metrics (disk usage, CPU load, network traffic) and yields current measurements once a second.
Defined Under Namespace
Classes: Monitor
Class Method Summary collapse
-
.monitor(cycle_length_seconds) ⇒ Object
This method yields hashes with these keys:.
Class Method Details
.monitor(cycle_length_seconds) ⇒ Object
This method yields hashes with these keys:
net_errors_1min: ... # network errors in the last minute
net_errors_5min: ... # network errors in the last 5 minutes
net_errors_15min: ... # network errors in the last 15 minutes
net_in_1min: ... # incoming network traffic in the last minute (bytes)
net_in_5min: ... # incoming network traffic in the last 5 minutes (bytes)
net_in_15min: ... # incoming network traffic in the last 15 minutes (bytes)
net_out_1min: ... # outgoing network traffic in the last minute (bytes)
net_out_5min: ... # outgoing network traffic in the last 5 minutes (bytes)
net_out_15min: ... # outgoing network traffic in the last 15 minutes (bytes)
uptime: ... # uptime (seconds)
cpu_load_1min: ... # cpu load
cpu_load_5min: ... # cpu load
cpu_load_15min: ... # cpu load
disk_used: ... # used disk space, over all disks
disk_available: ... # available disk space, over all disks
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tools/heartbeat.rb', line 55 def self.monitor(cycle_length_seconds) monitor = Monitor.new(cycle_length_seconds) loop do measurement = monitor.measure do_continue = yield measurement break if do_continue == false monitor.sleep end end |