예제 #1
0
 def timeout_schedule(self, obj):
     if obj.kind == "simple":
         return format_duration(obj.timeout)
     elif obj.kind == "cron":
         return obj.schedule
     else:
         return "Unknown"
예제 #2
0
 def timeout_schedule(self, obj):
     if obj.kind == "simple":
         return format_duration(obj.timeout)
     elif obj.kind == "cron":
         return obj.schedule
     else:
         return "Unknown"
예제 #3
0
    def notify(self, check, notification=None) -> None:
        if not settings.PD_ENABLED:
            raise TransportError("PagerDuty notifications are not enabled.")

        details = {
            "Project": check.project.name,
            "Total pings": check.n_pings,
            "Last ping": tmpl("pd_last_ping.html", check=check),
        }
        if check.desc:
            details["Description"] = check.desc
        if check.tags:
            details["Tags"] = ", ".join(check.tags_list())
        if check.kind == "simple":
            details["Period"] = format_duration(check.timeout)
        if check.kind == "cron":
            details["Schedule"] = check.schedule

        description = tmpl("pd_description.html", check=check)
        payload = {
            "service_key": self.channel.pd_service_key,
            "incident_key": str(check.code),
            "event_type": "trigger" if check.status == "down" else "resolve",
            "description": description,
            "client": settings.SITE_NAME,
            "client_url": check.details_url(),
            "details": details,
        }

        self.post(self.URL, json=payload)
예제 #4
0
def hc_duration(td):
    return format_duration(td)
예제 #5
0
def hc_duration(td):
    return format_duration(td)