app/models/my_nagios/check.rb in my_nagios-0.0.21 vs app/models/my_nagios/check.rb in my_nagios-0.0.22
- old
+ new
@@ -21,14 +21,14 @@
result = ssh.exec! self.command
status = self.determinate_status_by_response(result)
self.additional_command_result = ssh.exec!(self.additional_command) if not self.additional_command.blank? and status.eql?(:critical)
- self.update(state: :completed, status: status, latest_state: result, latest_updated_at: Time.now)
+ self.update(state: :completed, status: status, latest_state: result, latest_updated_at: Time.now, retry_count: 0)
end
rescue => e
- self.update(state: :completed, status: :info, latest_state: e, latest_updated_at: Time.now)
+ self.update(state: :completed, status: :info, latest_state: e, latest_updated_at: Time.now, retry_count: (self.retry_count + 1))
end
end
def self.multiple_run!(check_ids, config)
check_list = MyNagios::Check.where(id: check_ids)
@@ -41,15 +41,15 @@
result = ssh.exec! check.command
status = check.determinate_status_by_response(result)
check.additional_command_result = ssh.exec!(check.additional_command) if not check.additional_command.blank? and status.eql?(:critical)
- check.update(state: :completed, status: status, latest_state: result, latest_updated_at: Time.now)
+ check.update(state: :completed, status: status, latest_state: result, latest_updated_at: Time.now, retry_count: 0)
end
end
rescue => e
- check_list.each { |check| check.update(state: :completed, status: :info, latest_state: e, latest_updated_at: Time.now) }
+ check_list.each { |check| check.update(state: :completed, status: :info, latest_state: e, latest_updated_at: Time.now, retry_count: (check.retry_count + 1)) }
end
end
def determinate_status_by_response(response)
return :critical if not regexp.blank? and response =~ /#{regexp}/