mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-17 18:22:33 +00:00
Fix the Splunk On-Call integration to use Flip.new_status
This commit is contained in:
parent
6e27d88ec9
commit
3301cce251
3 changed files with 12 additions and 8 deletions
|
@ -18,7 +18,9 @@ class NotifyVictorOpsTestCase(BaseTestCase):
|
|||
|
||||
self.check = Check(project=self.project)
|
||||
self.check.name = "Foo"
|
||||
self.check.status = "down"
|
||||
# Transport classes should use flip.new_status,
|
||||
# so the status "paused" should not appear anywhere
|
||||
self.check.status = "paused"
|
||||
self.check.last_ping = now() - td(minutes=61)
|
||||
self.check.save()
|
||||
|
||||
|
@ -57,8 +59,8 @@ class NotifyVictorOpsTestCase(BaseTestCase):
|
|||
mock_post.return_value.status_code = 200
|
||||
|
||||
self.check.name = "Foo & Bar"
|
||||
self.check.status = "up"
|
||||
self.check.save()
|
||||
self.flip.new_status = "up"
|
||||
|
||||
self.channel.notify(self.flip)
|
||||
|
||||
|
|
|
@ -784,16 +784,18 @@ class VictorOps(HttpTransport):
|
|||
permanent = response.status_code == 404
|
||||
raise TransportError(message, permanent=permanent)
|
||||
|
||||
def notify(self, check: Check, notification: Notification) -> None:
|
||||
def notify_flip(self, flip: Flip, notification: Notification) -> None:
|
||||
if not settings.VICTOROPS_ENABLED:
|
||||
raise TransportError("Splunk On-Call notifications are not enabled.")
|
||||
|
||||
description = tmpl("victorops_description.html", check=check)
|
||||
mtype = "CRITICAL" if check.status == "down" else "RECOVERY"
|
||||
description = tmpl(
|
||||
"victorops_description.html", check=flip.owner, status=flip.new_status
|
||||
)
|
||||
mtype = "CRITICAL" if flip.new_status == "down" else "RECOVERY"
|
||||
payload = {
|
||||
"entity_id": str(check.code),
|
||||
"entity_id": str(flip.owner.code),
|
||||
"message_type": mtype,
|
||||
"entity_display_name": check.name_then_code(),
|
||||
"entity_display_name": flip.owner.name_then_code(),
|
||||
"state_message": description,
|
||||
"monitoring_tool": settings.SITE_NAME,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% load humanize %}
|
||||
{% if check.status == "down" %}
|
||||
{% if status == "down" %}
|
||||
{{ check.name_then_code|safe }} is DOWN.
|
||||
{% if check.last_ping %}Last ping was {{ check.last_ping|naturaltime }}.{% endif %}
|
||||
{% else %}
|
||||
|
|
Loading…
Add table
Reference in a new issue