Skip to content

Commit

Permalink
Merge 38e697c into bf44118
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvance committed Jan 23, 2018
2 parents bf44118 + 38e697c commit f86b75f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
11 changes: 9 additions & 2 deletions hc/api/management/commands/sendalerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ def handle_many(self):
now = timezone.now()
going_down = query.filter(alert_after__lt=now, status="up")
going_up = query.filter(alert_after__gt=now, status="down")
going_nag = query.filter(nag_after__lt=now, status="down", nag_mode=True)
# checks that are in nag_mode and the status is down, this will get all checks to be nagged
checks_to_nag = query.filter(nag_after__lt=now, status="down", nag_mode=True)
#job runs often
# going_often = query.filter(alert_after__lt=now, status="often")
# Don't combine this in one query so Postgres can query using index:
checks = list(going_down.iterator()) + list(going_up.iterator()) + list(going_nag.iterator())
checks = list(going_down.iterator()) + list(going_up.iterator()) + list(checks_to_nag.iterator())
if not checks:
return False

Expand All @@ -49,7 +50,13 @@ def handle_one(self, check):
check.save()

if check.status == "down":
# this will check the status has gone down
if check.nag_mode == True:
'''
This will ensure that after a check has gone down then
the nag_mode is set to True. This is done at the same time
as when the first alert has been sent.
'''
check.nag_after = (timezone.now() + check.nag_interval)
check.save()

Expand Down
5 changes: 5 additions & 0 deletions static/css/my_checks.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
#nag-slider.noUi-connect {
background: #f0ad4e;
}
#nag_check{
width: 470px;
background-color: #fafafa;
border-radius: 3px;
}

#period-slider .noUi-value, #grace-slider .noUi-value, #nag-slider .noUi-value {
width: 60px;
Expand Down
2 changes: 1 addition & 1 deletion templates/front/my_checks.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h4 class="update-timeout-title">Name and Tags</h4>
title="Tag Nag Mode on.">
Nag Mode
</span>
<select name="nag_mode">
<select name="nag_mode" id="nag_check">
<option value="True">True</option>
<option selected="selected" value="False">False</option>
</select>
Expand Down
3 changes: 0 additions & 3 deletions templates/front/my_checks_desktop.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
{% elif check.get_status == "down" %}
<span class="status icon-down"></span>
{% endif %}
{% if check.nag_mode == True %}
<span class="glyphicon glyphicon-exclamation-sign" style="color:rgb(235, 82, 82)"></span>
{% endif %}
</td>
<td class="name-cell">
<div data-name="{{ check.name }}"
Expand Down

0 comments on commit f86b75f

Please sign in to comment.