Skip to content
Snippets Groups Projects
Commit 0c85b6b2 authored by Nico Vermaas's avatar Nico Vermaas
Browse files
add service monitor to monitoring page
parent f4999121
No related branches found
No related tags found
2 merge requests!181https://support.astron.nl/jira/browse/SDC-499,!179https://support.astron.nl/jira/browse/SDC-499
python manage.py migrate taskdatabase 0010 --settings=atdb.settings.dev
\ No newline at end of file
......@@ -145,3 +145,18 @@ class Monitor(models.Model):
# the representation of the value in the REST API
def __str__(self):
return str(self.name)+' - '+str(self.timestamp) + ' - ' + self.status
class LatestMonitor(models.Model):
name = models.CharField(max_length=50, default="unknown")
type = models.CharField(max_length=20, default="ldv-service", null=True, blank=True)
timestamp = models.DateTimeField(default=datetime.utcnow, blank=True)
hostname = models.CharField(max_length=50, default="unknown")
process_id = models.IntegerField(null=True, blank=True)
description = models.CharField(max_length=255, blank=True, null=True)
status = models.CharField(max_length=50, default="ok", null=True)
metadata = models.JSONField(null=True, blank=True)
# the representation of the value in the REST API
def __str__(self):
return str(self.name)+' - '+str(self.timestamp) + ' - ' + self.status
\ No newline at end of file
......@@ -209,10 +209,13 @@ def convert_monitor_to_html(monitor_data):
key = record.name
value = record.status
filter = record.description
line = '<tr>'
if "error" in record.status:
line = '<tr class="' + record.status + '" >'
line += "<td><b>" + str(record.name) + "</b></td>"
line += "<td>" + str(record.hostname) + "</td>"
line += "<td>" + str(record.status) + "</td>"
line += '<td class="' + record.status + '" >' + str(record.status) + "</td>"
line += "<td>" + str(record.timestamp) + "</td>"
line += "<td>" + str(record.process_id) + "</td>"
line += "<td>" + str(record.description) + "</td>"
......
......@@ -39,7 +39,7 @@ TD {
font-weight: bold;
}
.processed {
.processed,.ok {
color: green;
font-weight: bold;
}
......
......@@ -80,7 +80,7 @@
{% include 'taskdatabase/pagination.html' %}
</div>
</div>
<p class="footer"> Version 1.0.0 (28 jan 2021 - 14:00)
<p class="footer"> Version 1.0.0 (31 jan 2021 - 10:00)
</div>
......
......@@ -326,9 +326,9 @@ def WorkflowDetails(request, id):
def ShowMonitoring(request):
# get the latest value of each unique combination of service name and hostname.
monitor_data = Monitor.objects.all()
distinct_services_per_host = Monitor.objects.all().order_by('name', 'hostname', '-timestamp').distinct('name', 'hostname')
monitor_results = algorithms.convert_monitor_to_html(monitor_data)
monitor_results = algorithms.convert_monitor_to_html(distinct_services_per_host)
return render(request, "taskdatabase/monitoring.html", {'monitor_results': monitor_results})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment