Class: DeadmanCheck::SwitchMonitor
- Inherits:
-
Object
- Object
- DeadmanCheck::SwitchMonitor
- Defined in:
- lib/deadman_check_switch.rb
Overview
Switch class
Instance Attribute Summary collapse
-
#alert_to ⇒ Object
Returns the value of attribute alert_to.
-
#daemon_sleep ⇒ Object
Returns the value of attribute daemon_sleep.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#recurse ⇒ Object
Returns the value of attribute recurse.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(host, port, target, alert_to, recurse, daemon_sleep) ⇒ SwitchMonitor
constructor
A new instance of SwitchMonitor.
- #run_check_daemon ⇒ Object
- #run_check_once ⇒ Object
Constructor Details
#initialize(host, port, target, alert_to, recurse, daemon_sleep) ⇒ SwitchMonitor
Returns a new instance of SwitchMonitor.
12 13 14 15 16 17 18 19 |
# File 'lib/deadman_check_switch.rb', line 12 def initialize(host, port, target, alert_to, recurse, daemon_sleep) @host = host @port = port @target = target @alert_to = alert_to @recurse = recurse @daemon_sleep = daemon_sleep.to_i end |
Instance Attribute Details
#alert_to ⇒ Object
Returns the value of attribute alert_to.
10 11 12 |
# File 'lib/deadman_check_switch.rb', line 10 def alert_to @alert_to end |
#daemon_sleep ⇒ Object
Returns the value of attribute daemon_sleep.
10 11 12 |
# File 'lib/deadman_check_switch.rb', line 10 def daemon_sleep @daemon_sleep end |
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/deadman_check_switch.rb', line 10 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
10 11 12 |
# File 'lib/deadman_check_switch.rb', line 10 def port @port end |
#recurse ⇒ Object
Returns the value of attribute recurse.
10 11 12 |
# File 'lib/deadman_check_switch.rb', line 10 def recurse @recurse end |
#target ⇒ Object
Returns the value of attribute target.
10 11 12 |
# File 'lib/deadman_check_switch.rb', line 10 def target @target end |
Instance Method Details
#run_check_daemon ⇒ Object
36 37 38 39 40 41 |
# File 'lib/deadman_check_switch.rb', line 36 def run_check_daemon loop do run_check_once sleep(@daemon_sleep) end end |
#run_check_once ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/deadman_check_switch.rb', line 25 def run_check_once recorded_epochs = get_recorded_epochs(@host, @port, @target, @recurse) current_epoch = DeadmanCheck::DeadmanCheckGlobal.new.get_epoch_time.to_i if @recurse check_recursive_recorded_epochs(recorded_epochs, current_epoch) else record = parse_recorded_epoch(recorded_epochs) check_recorded_epoch(record, current_epoch) end end |