Merge pull request #1 from Labgoo/feature/Add_last_result_content_to_email_alert

add last result content to the email body
This commit is contained in:
Barak Cohen 2014-11-27 14:31:07 +02:00
commit 1029ebf5c5
2 changed files with 2 additions and 1 deletions

View File

@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
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 %}. 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 %} {% if service.overall_status != service.PASSING_STATUS %}
CHECKS FAILING:{% for check in service.all_failing_checks %} CHECKS FAILING:{% for check in service.all_failing_checks %}
FAILING - {{ check.name }} - Type: {{ check.check_category }} - Importance: {{ check.get_importance_display }}{% endfor %} FAILING - {{ check.name }} - Type: {{ check.check_category }} - Importance: {{ check.get_importance_display }} - Last Result: {{ check.last_result.raw_data }}{% endfor %}
{% if service.all_passing_checks %} {% if service.all_passing_checks %}
Passing checks:{% for check in service.all_passing_checks %} Passing checks:{% for check in service.all_passing_checks %}
PASSING - {{ check.name }} - Type: {{ check.check_category }} - Importance: {{ check.get_importance_display }}{% endfor %} PASSING - {{ check.name }} - Type: {{ check.check_category }} - Importance: {{ check.get_importance_display }}{% endfor %}

View File

@ -437,6 +437,7 @@ class StatusCheck(PolymorphicModel):
# on time_complete # on time_complete
return StatusCheckResult.objects.filter(check=self).order_by('-id').defer('raw_data')[:10] return StatusCheckResult.objects.filter(check=self).order_by('-id').defer('raw_data')[:10]
@property
def last_result(self): def last_result(self):
try: try:
return StatusCheckResult.objects.filter(check=self).order_by('-id').defer('raw_data')[0] return StatusCheckResult.objects.filter(check=self).order_by('-id').defer('raw_data')[0]