mirror of https://github.com/status-im/cabot.git
Allow for the scheme of alert links to be configured
This commit is contained in:
parent
956c1f47d5
commit
80f0ccb4b3
|
@ -16,5 +16,6 @@ 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_SCHEME = os.environ.get('WWW_SCHEME', "http")
|
||||
ALERT_INTERVAL = os.environ.get('ALERT_INTERVAL', 10)
|
||||
NOTIFICATION_INTERVAL = os.environ.get('NOTIFICATION_INTERVAL', 120)
|
||||
|
|
|
@ -12,7 +12,7 @@ import logging
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
email_template = """Service {{ service.name }} https://{{ host }}{% url service pk=service.id %} {% if service.overall_status != service.PASSING_STATUS %}alerting with status: {{ service.overall_status }}{% else %}is back to normal{% endif %}.
|
||||
email_template = """Service {{ service.name }} {{ scheme }}://{{ host }}{% url service pk=service.id %} {% if service.overall_status != service.PASSING_STATUS %}alerting with status: {{ service.overall_status }}{% else %}is back to normal{% endif %}.
|
||||
{% if service.overall_status != service.PASSING_STATUS %}
|
||||
CHECKS FAILING:{% for check in service.all_failing_checks %}
|
||||
FAILING - {{ check.name }} - Type: {{ check.check_category }} - Importance: {{ check.get_importance_display }}{% endfor %}
|
||||
|
@ -23,9 +23,9 @@ Passing checks:{% for check in service.all_passing_checks %}
|
|||
{% endif %}
|
||||
"""
|
||||
|
||||
hipchat_template = "Service {{ service.name }} {% if service.overall_status == service.PASSING_STATUS %}is back to normal{% else %}reporting {{ service.overall_status }} status{% endif %}: https://{{ host }}{% url service pk=service.id %}. {% if service.overall_status != service.PASSING_STATUS %}Checks failing:{% for check in service.all_failing_checks %} {{ check.name }}{% if check.last_result.error %} ({{ check.last_result.error|safe }}){% endif %}{% endfor %}{% endif %}{% if alert %}{% for alias in users %} @{{ alias }}{% endfor %}{% endif %}"
|
||||
hipchat_template = "Service {{ service.name }} {% if service.overall_status == service.PASSING_STATUS %}is back to normal{% else %}reporting {{ service.overall_status }} status{% endif %}: {{ scheme }}://{{ host }}{% url service pk=service.id %}. {% if service.overall_status != service.PASSING_STATUS %}Checks failing:{% for check in service.all_failing_checks %} {{ check.name }}{% if check.last_result.error %} ({{ check.last_result.error|safe }}){% endif %}{% endfor %}{% endif %}{% if alert %}{% for alias in users %} @{{ alias }}{% endfor %}{% endif %}"
|
||||
|
||||
sms_template = "Service {{ service.name }} {% if service.overall_status == service.PASSING_STATUS %}is back to normal{% else %}reporting {{ service.overall_status }} status{% endif %}: https://{{ host }}{% url service pk=service.id %}"
|
||||
sms_template = "Service {{ service.name }} {% if service.overall_status == service.PASSING_STATUS %}is back to normal{% else %}reporting {{ service.overall_status }} status{% endif %}: {{ scheme }}://{{ host }}{% url service pk=service.id %}"
|
||||
|
||||
telephone_template = "This is an urgent message from Arachnys monitoring. Service \"{{ service.name }}\" is erroring. Please check Cabot urgently."
|
||||
|
||||
|
@ -49,6 +49,7 @@ def send_email_alert(service, users, duty_officers):
|
|||
c = Context({
|
||||
'service': service,
|
||||
'host': settings.WWW_HTTP_HOST,
|
||||
'scheme': settings.WWW_SCHEME
|
||||
})
|
||||
if service.overall_status != service.PASSING_STATUS:
|
||||
if service.overall_status == service.CRITICAL_STATUS:
|
||||
|
@ -88,6 +89,7 @@ def send_hipchat_alert(service, users, duty_officers):
|
|||
'service': service,
|
||||
'users': hipchat_aliases,
|
||||
'host': settings.WWW_HTTP_HOST,
|
||||
'scheme': settings.WWW_SCHEME,
|
||||
'alert': alert,
|
||||
})
|
||||
message = Template(hipchat_template).render(c)
|
||||
|
@ -119,6 +121,7 @@ def send_sms_alert(service, users, duty_officers):
|
|||
c = Context({
|
||||
'service': service,
|
||||
'host': settings.WWW_HTTP_HOST,
|
||||
'scheme': settings.WWW_SCHEME,
|
||||
})
|
||||
message = Template(sms_template).render(c)
|
||||
for mobile in mobiles:
|
||||
|
|
|
@ -43,4 +43,5 @@ TWILIO_AUTH_TOKEN=your_auth_token
|
|||
TWILIO_OUTGOING_NUMBER=+14155551234
|
||||
|
||||
# Used for pointing links back in alerts etc.
|
||||
WWW_HTTP_HOST=localhost
|
||||
WWW_HTTP_HOST=localhost
|
||||
WWW_SCHEME=http
|
||||
|
|
|
@ -43,4 +43,5 @@ TWILIO_AUTH_TOKEN=your_auth_token
|
|||
TWILIO_OUTGOING_NUMBER=+14155551234
|
||||
|
||||
# Used for pointing links back in alerts etc.
|
||||
WWW_HTTP_HOST=cabot.example.com
|
||||
WWW_HTTP_HOST=cabot.example.com
|
||||
WWW_SCHEME=http
|
||||
|
|
Loading…
Reference in New Issue