Skip to content
Snippets Groups Projects
Commit 0fcf79d2 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

status is 'unknown' when late

repaired crazy timeformat
parent 5d08b429
Branches
Tags
2 merge requests!211status is 'unknown' when late,!210status is 'unknown' when late
...@@ -250,6 +250,9 @@ def convert_monitor_to_html(request, monitor_data): ...@@ -250,6 +250,9 @@ def convert_monitor_to_html(request, monitor_data):
try: try:
for record in monitor_data: for record in monitor_data:
# iterate through the dict of key/values # iterate through the dict of key/values
d1 = datetime.utcnow().replace(tzinfo=None)
d2 = record.timestamp.replace(tzinfo=None)
delta = d1 - d2
# http://localhost:8000/atdb/monitor/?name=stager&hostname=localhost # http://localhost:8000/atdb/monitor/?name=stager&hostname=localhost
link_to_service_history = construct_link_to_monitor_history(request, record.name, record.name, record.hostname) link_to_service_history = construct_link_to_monitor_history(request, record.name, record.name, record.hostname)
...@@ -261,16 +264,14 @@ def convert_monitor_to_html(request, monitor_data): ...@@ -261,16 +264,14 @@ def convert_monitor_to_html(request, monitor_data):
#line += "<td><b>" + str(record.name) + "</b></td>" #line += "<td><b>" + str(record.name) + "</b></td>"
line += "<td><b>" + link_to_service_history + "</b></td>" line += "<td><b>" + link_to_service_history + "</b></td>"
line += "<td>" + str(record.hostname) + "</td>" line += "<td>" + str(record.hostname) + "</td>"
line += '<td class="' + record.status + '" >' + str(record.status) + "</td>"
d1 = datetime.utcnow().replace(tzinfo=None)
d2 = record.timestamp.replace(tzinfo=None)
delta = d1 - d2
# if the heartbeat is 30 minutes late, show '(late)' in red # if the heartbeat is 30 minutes late, show '(late)' in red
if delta.seconds > 1800: if delta.seconds > 1800:
line += "<td><i>unknown</i></td>"
line += '<td class="error">' + str(record.timestamp.strftime(TIME_FORMAT)) + " - (late)</td>" line += '<td class="error">' + str(record.timestamp.strftime(TIME_FORMAT)) + " - (late)</td>"
else: else:
line += '<td>' + str(record.timestamp) + "</td>" line += '<td class="' + record.status + '" >' + str(record.status) + "</td>"
line += '<td>' + str(record.timestamp.strftime(TIME_FORMAT)) + "</td>"
line += "<td>" + str(record.process_id) + "</td>" line += "<td>" + str(record.process_id) + "</td>"
line += "<td>" + str(record.description) + "</td>" line += "<td>" + str(record.description) + "</td>"
line += "</tr>" line += "</tr>"
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 1.0.0 (4 mar 2021 - 11:00) <p class="footer"> Version 1.0.0 (4 mar 2021 - 15:00)
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment