Fixed inherent issue with class variable.
This commit is contained in:
parent
5ac1bd108a
commit
ea9e323df3
3 changed files with 18 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel::Filter::Icinga < Channel::Filter::MonitoringBase
|
class Channel::Filter::Icinga < Channel::Filter::MonitoringBase
|
||||||
# rubocop:disable Style/ClassVars
|
def self.integration_name
|
||||||
@@integration = 'icinga'
|
'icinga'
|
||||||
# rubocop:enable Style/ClassVars
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel::Filter::MonitoringBase
|
class Channel::Filter::MonitoringBase
|
||||||
# rubocop:disable Style/ClassVars
|
|
||||||
@@integration = 'to_be_defined'
|
|
||||||
# rubocop:enable Style/ClassVars
|
|
||||||
|
|
||||||
# according
|
# according
|
||||||
|
|
||||||
|
@ -16,11 +13,11 @@ class Channel::Filter::MonitoringBase
|
||||||
# https://github.com/NagiosEnterprises/nagioscore/blob/754218e67653929a58938b99ef6b6039b6474fe4/sample-config/template-object/commands.cfg.in#L35
|
# https://github.com/NagiosEnterprises/nagioscore/blob/754218e67653929a58938b99ef6b6039b6474fe4/sample-config/template-object/commands.cfg.in#L35
|
||||||
|
|
||||||
def self.run(_channel, mail)
|
def self.run(_channel, mail)
|
||||||
|
integration = integration_name
|
||||||
return if !Setting.get("#{@@integration}_integration")
|
return if !Setting.get("#{integration}_integration")
|
||||||
sender = Setting.get("#{@@integration}_sender")
|
sender = Setting.get("#{integration}_sender")
|
||||||
auto_close = Setting.get("#{@@integration}_auto_close")
|
auto_close = Setting.get("#{integration}_auto_close")
|
||||||
auto_close_state_id = Setting.get("#{@@integration}_auto_close_state_id")
|
auto_close_state_id = Setting.get("#{integration}_auto_close_state_id")
|
||||||
state_recovery_match = 'OK'
|
state_recovery_match = 'OK'
|
||||||
|
|
||||||
return if !mail[:from]
|
return if !mail[:from]
|
||||||
|
@ -53,11 +50,11 @@ class Channel::Filter::MonitoringBase
|
||||||
Ticket.where(state: open_states).each {|ticket|
|
Ticket.where(state: open_states).each {|ticket|
|
||||||
next if !ticket.preferences
|
next if !ticket.preferences
|
||||||
next if !ticket.preferences['integration']
|
next if !ticket.preferences['integration']
|
||||||
next if ticket.preferences['integration'] != @@integration
|
next if ticket.preferences['integration'] != integration
|
||||||
next if !ticket.preferences[@@integration]
|
next if !ticket.preferences[integration]
|
||||||
next if !ticket.preferences[@@integration]['host']
|
next if !ticket.preferences[integration]['host']
|
||||||
next if ticket.preferences[@@integration]['host'] != result['host']
|
next if ticket.preferences[integration]['host'] != result['host']
|
||||||
next if ticket.preferences[@@integration]['service'] != result['service']
|
next if ticket.preferences[integration]['service'] != result['service']
|
||||||
|
|
||||||
# found open ticket for service+host
|
# found open ticket for service+host
|
||||||
mail[ 'x-zammad-ticket-id'.to_sym ] = ticket.id
|
mail[ 'x-zammad-ticket-id'.to_sym ] = ticket.id
|
||||||
|
@ -78,8 +75,8 @@ class Channel::Filter::MonitoringBase
|
||||||
mail[ 'x-zammad-ticket-preferences'.to_sym ] = {}
|
mail[ 'x-zammad-ticket-preferences'.to_sym ] = {}
|
||||||
end
|
end
|
||||||
preferences = {}
|
preferences = {}
|
||||||
preferences['integration'] = @@integration
|
preferences['integration'] = integration
|
||||||
preferences[@@integration] = result
|
preferences[integration] = result
|
||||||
preferences.each {|key, value|
|
preferences.each {|key, value|
|
||||||
mail[ 'x-zammad-ticket-preferences'.to_sym ][key] = value
|
mail[ 'x-zammad-ticket-preferences'.to_sym ][key] = value
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Channel::Filter::Nagios < Channel::Filter::MonitoringBase
|
class Channel::Filter::Nagios < Channel::Filter::MonitoringBase
|
||||||
# rubocop:disable Style/ClassVars
|
def self.integration_name
|
||||||
@@integration = 'nagios'
|
'nagios'
|
||||||
# rubocop:enable Style/ClassVars
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue