Skip to content

Commit

Permalink
Merge branch 'set_link_scheme' of github.com:Hebo/cabot into Hebo-set…
Browse files Browse the repository at this point in the history
…_link_scheme
  • Loading branch information
dbuxton committed Mar 2, 2014
2 parents 6d6db6c + b8d537c commit fd730d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/cabot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
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', "https")
ALERT_INTERVAL = os.environ.get('ALERT_INTERVAL', 10)
NOTIFICATION_INTERVAL = os.environ.get('NOTIFICATION_INTERVAL', 120)
9 changes: 6 additions & 3 deletions app/cabotapp/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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 %}
Expand All @@ -23,9 +23,9 @@
{% 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."

Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
mobiles = list(set(mobiles))
Expand Down
3 changes: 2 additions & 1 deletion conf/development.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion conf/production.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fd730d2

Please sign in to comment.