mirror of
https://github.com/status-im/cabot.git
synced 2025-02-24 10:28:06 +00:00
Merge pull request #11 from ryanaudiencepi/interval-to-settings
make alert and notification interval customizable
This commit is contained in:
commit
e1e40dbeb2
@ -15,4 +15,6 @@ TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID')
|
||||
TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
|
||||
TWILIO_OUTGOING_NUMBER = os.environ.get('TWILIO_OUTGOING_NUMBER')
|
||||
CALENDAR_ICAL_URL = os.environ.get('CALENDAR_ICAL_URL')
|
||||
WWW_HTTP_HOST = os.environ.get('WWW_HTTP_HOST')
|
||||
WWW_HTTP_HOST = os.environ.get('WWW_HTTP_HOST')
|
||||
ALERT_INTERVAL = os.environ.get('ALERT_INTERVAL', 10)
|
||||
NOTIFICATION_INTERVAL = os.environ.get('NOTIFICATION_INTERVAL', 120)
|
||||
|
@ -1,4 +1,5 @@
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from polymorphic import PolymorphicModel
|
||||
from django.db.models import F
|
||||
from django.contrib.admin.models import User
|
||||
@ -165,12 +166,12 @@ class Service(models.Model):
|
||||
if not self.alerts_enabled:
|
||||
return
|
||||
if self.overall_status != self.PASSING_STATUS:
|
||||
# Don't alert every time - only every 10 mins for errors and critical, and 120 mins for warnings
|
||||
# Don't alert every time
|
||||
if self.overall_status == self.WARNING_STATUS:
|
||||
if self.last_alert_sent and (timezone.now() - timedelta(minutes=120)) < self.last_alert_sent:
|
||||
if self.last_alert_sent and (timezone.now() - timedelta(minutes=settings.NOTIFICATION_INTERVAL)) < self.last_alert_sent:
|
||||
return
|
||||
elif self.overall_status in (self.CRITICAL_STATUS, self.ERROR_STATUS):
|
||||
if self.last_alert_sent and (timezone.now() - timedelta(minutes=10)) < self.last_alert_sent:
|
||||
if self.last_alert_sent and (timezone.now() - timedelta(minutes=settings.ALERT_INTERVAL)) < self.last_alert_sent:
|
||||
return
|
||||
self.last_alert_sent = timezone.now()
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user