Added support of new icinga 2.7 notification templates (82a5c5a624 (diff-5a9d2fc2eb1c21d6a011c9c06b37fb5b)
).
This commit is contained in:
parent
b2ece28306
commit
7ce18e86f6
2 changed files with 42 additions and 2 deletions
|
@ -45,6 +45,13 @@ class Channel::Filter::MonitoringBase
|
||||||
# check min. params
|
# check min. params
|
||||||
return if result['host'].blank?
|
return if result['host'].blank?
|
||||||
|
|
||||||
|
# get state from body
|
||||||
|
if result['state'].blank?
|
||||||
|
if mail[:body] =~ /==>.*\sis\s(.+?)\!\s+?<==/
|
||||||
|
result['state'] = $1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# check if ticket with host is open
|
# check if ticket with host is open
|
||||||
customer = User.lookup(id: session_user_id)
|
customer = User.lookup(id: session_user_id)
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ IPv4: 127.0.0.1="
|
||||||
assert_equal('apn4711.dc.example.com (Display Name: "apn4711.dc.example.com")', ticket_0.preferences['icinga']['host'])
|
assert_equal('apn4711.dc.example.com (Display Name: "apn4711.dc.example.com")', ticket_0.preferences['icinga']['host'])
|
||||||
assert_equal('CHECK_RBL CRITICAL - apn4711.dc.example.com BLACKLISTED on 1 server of 38 (ix.dnsbl.example.com)', ticket_0.preferences['icinga']['info'])
|
assert_equal('CHECK_RBL CRITICAL - apn4711.dc.example.com BLACKLISTED on 1 server of 38 (ix.dnsbl.example.com)', ticket_0.preferences['icinga']['info'])
|
||||||
assert_equal('RBL check (Display Name: "RBL check")', ticket_0.preferences['icinga']['service'])
|
assert_equal('RBL check (Display Name: "RBL check")', ticket_0.preferences['icinga']['service'])
|
||||||
assert_nil(ticket_0.preferences['icinga']['state'])
|
assert_equal('CRITICAL', ticket_0.preferences['icinga']['state'])
|
||||||
|
|
||||||
# RBL check II
|
# RBL check II
|
||||||
email_raw_string = "To: support@example.com
|
email_raw_string = "To: support@example.com
|
||||||
|
@ -108,9 +108,42 @@ IPv4: 127.0.0.1="
|
||||||
assert_equal('apn4711.dc.example.com (Display Name: "apn4711.dc.example.com")', ticket_0_1.preferences['icinga']['host'])
|
assert_equal('apn4711.dc.example.com (Display Name: "apn4711.dc.example.com")', ticket_0_1.preferences['icinga']['host'])
|
||||||
assert_equal('CHECK_RBL CRITICAL - apn4711.dc.example.com BLACKLISTED on 1 server of 38 (ix.dnsbl.example.com)', ticket_0_1.preferences['icinga']['info'])
|
assert_equal('CHECK_RBL CRITICAL - apn4711.dc.example.com BLACKLISTED on 1 server of 38 (ix.dnsbl.example.com)', ticket_0_1.preferences['icinga']['info'])
|
||||||
assert_equal('RBL check (Display Name: "RBL check")', ticket_0_1.preferences['icinga']['service'])
|
assert_equal('RBL check (Display Name: "RBL check")', ticket_0_1.preferences['icinga']['service'])
|
||||||
assert_nil(ticket_0_1.preferences['icinga']['state'])
|
assert_equal('CRITICAL', ticket_0_1.preferences['icinga']['state'])
|
||||||
assert_equal(ticket_0_1.id, ticket_0.id)
|
assert_equal(ticket_0_1.id, ticket_0.id)
|
||||||
|
|
||||||
|
email_raw_string = "To: support@example.com
|
||||||
|
Subject: [PROBLEM] RBL check on apn4711.dc.example.com is OK!
|
||||||
|
User-Agent: Heirloom mailx 12.5 7/5/10
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=us-ascii
|
||||||
|
Content-Transfer-Encoding: quoted-printable
|
||||||
|
Message-Id: <20160131094621.29ECD400F29C-icinga-1-2@monitoring.znuny.com>
|
||||||
|
From: icinga@monitoring.example.com (icinga)
|
||||||
|
|
||||||
|
***** Icinga 2 Service Monitoring on apn4711.dc.example.com *****
|
||||||
|
|
||||||
|
=3D=3D> RBL check on apn4711.dc.example.com is OK! <=3D=3D
|
||||||
|
|
||||||
|
Info: CHECK_RBL OK - apn4711.dc.example.com BLACKLISTED on 1 server of=
|
||||||
|
38 (ix.dnsbl.example.com)=20
|
||||||
|
|
||||||
|
When: 2017-08-06 22:18:43 +0200
|
||||||
|
Service: RBL check (Display Name: \"RBL check\")
|
||||||
|
Host: apn4711.dc.example.com (Display Name: \"apn4711.dc.example.com\")
|
||||||
|
IPv4: 127.0.0.1="
|
||||||
|
|
||||||
|
ticket_0_2, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
||||||
|
assert_equal('closed', ticket_0_2.state.name)
|
||||||
|
assert(ticket_0_2.preferences)
|
||||||
|
assert(ticket_0_2.preferences['integration'])
|
||||||
|
assert_equal('icinga', ticket_0_2.preferences['integration'])
|
||||||
|
assert(ticket_0_2.preferences['icinga'])
|
||||||
|
assert_equal('apn4711.dc.example.com (Display Name: "apn4711.dc.example.com")', ticket_0_2.preferences['icinga']['host'])
|
||||||
|
assert_equal('CHECK_RBL CRITICAL - apn4711.dc.example.com BLACKLISTED on 1 server of 38 (ix.dnsbl.example.com)', ticket_0_2.preferences['icinga']['info'])
|
||||||
|
assert_equal('RBL check (Display Name: "RBL check")', ticket_0_2.preferences['icinga']['service'])
|
||||||
|
assert_equal('CRITICAL', ticket_0_2.preferences['icinga']['state'])
|
||||||
|
assert_equal(ticket_0_2.id, ticket_0.id)
|
||||||
|
|
||||||
# matching sender - CPU Load/host.internal.loc
|
# matching sender - CPU Load/host.internal.loc
|
||||||
email_raw_string = "To: support@example.com
|
email_raw_string = "To: support@example.com
|
||||||
Subject: PROBLEM - host.internal.loc - CPU Load is WARNING
|
Subject: PROBLEM - host.internal.loc - CPU Load is WARNING
|
||||||
|
|
Loading…
Reference in a new issue