0
0
Fork 0
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:
Pēteris Caune 2024-04-12 15:37:43 +03:00
parent 6e27d88ec9
commit 3301cce251
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
3 changed files with 12 additions and 8 deletions

View file

@ -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)

View file

@ -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,
}

View file

@ -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 %}