app/models/my_nagios/check.rb in my_nagios-0.0.15 vs app/models/my_nagios/check.rb in my_nagios-0.0.16
- old
+ new
@@ -7,10 +7,12 @@
scope :enabled, -> { where(enabled: true) }
attr_accessor :additional_command_result
+ INFO_STATES = ['AuthenticationFailed message', 'No such file or directory']
+
def run!
begin
self.update(state: :running)
Net::SSH.start( self.host, self.user, MyNagios::Check.ssh_config(self.pem_key) ) do |ssh|
@@ -49,10 +51,10 @@
end
def determinate_status_by_response(response)
return :critical if not regexp.blank? and response =~ /#{regexp}/
return :critical if not response.scan('CRITICAL').blank?
- return :info if response.nil? or not response.scan('No such file or directory').blank?
+ return :info if response.nil? or MyNagios::INFO_STATES.any? { |msg| response.include?(msg) }
:success
end
def self.ssh_config(pem_key = nil)
config = { config: true, non_interactive: true, auth_methods: ['publickey', 'hostbased'] }