mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 21:18:16 -06:00
14729 worker detail
This commit is contained in:
parent
ddb7ec3f46
commit
ac8702a135
@ -61,7 +61,7 @@ class BackgroundTaskTable(BaseTable):
|
||||
|
||||
|
||||
class WorkerTable(BaseTable):
|
||||
name = tables.Column(verbose_name=_("Name"))
|
||||
name = tables.LinkColumn("core:worker", args=[A("name")], verbose_name=_("Name"))
|
||||
state = tables.Column(verbose_name=_("State"))
|
||||
birth_date = tables.DateTimeColumn(verbose_name=_("Birth"))
|
||||
pid = tables.Column(verbose_name=_("PID"))
|
||||
|
@ -30,6 +30,7 @@ urlpatterns = (
|
||||
path('background-queues/<int:queue_index>/<str:status>/', views.BackgroundTaskListView.as_view(), name='background_task_list'),
|
||||
path('background-tasks/<str:job_id>/', views.BackgroundTaskDetailView.as_view(), name='background_task'),
|
||||
path('background-workers/<int:queue_index>/', views.WorkerListView.as_view(), name='worker_list'),
|
||||
path('background-worker/<str:key>/', views.WorkerDetailView.as_view(), name='worker'),
|
||||
|
||||
# Config revisions
|
||||
path('config-revisions/', views.ConfigRevisionListView.as_view(), name='configrevision_list'),
|
||||
|
@ -418,6 +418,25 @@ class BackgroundTaskDetailView(UserPassesTestMixin, View):
|
||||
})
|
||||
|
||||
|
||||
class WorkerDetailView(UserPassesTestMixin, View):
|
||||
|
||||
def test_func(self):
|
||||
return self.request.user.is_staff
|
||||
|
||||
def get(self, request, key):
|
||||
# all the RQ queues should use the same connection
|
||||
config = QUEUES_LIST[0]
|
||||
worker = Worker.find_by_key('rq:worker:' + key, connection=get_redis_connection(config['connection_config']))
|
||||
# Convert microseconds to milliseconds
|
||||
worker.total_working_time = worker.total_working_time / 1000
|
||||
|
||||
return render(request, 'core/worker.html', {
|
||||
'worker': worker,
|
||||
'job': worker.get_current_job(),
|
||||
'total_working_time': worker.total_working_time * 1000,
|
||||
})
|
||||
|
||||
|
||||
#
|
||||
# Plugins
|
||||
#
|
||||
|
80
netbox/templates/core/worker.html
Normal file
80
netbox/templates/core/worker.html
Normal file
@ -0,0 +1,80 @@
|
||||
{% extends 'generic/object.html' %}
|
||||
{% load i18n %}
|
||||
{% load helpers %}
|
||||
{% load render_table from django_tables2 %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
<li class="breadcrumb-item"><a href="{% url 'core:background_queue_list' %}">{% trans 'Background Tasks' %}</a></li>
|
||||
{# <li class="breadcrumb-item"><a href="{% url 'core:background_task_list' queue_index=queue_index status=job.get_status %}">{{ queue.name }}</a></li> #}
|
||||
{% endblock breadcrumbs %}
|
||||
|
||||
{% block title %}{% trans "Worker Info" %} {{ job.id }}{% endblock %}
|
||||
|
||||
{% block object_identifier %}{% endblock %}
|
||||
|
||||
{% block controls %}
|
||||
<div class="controls">
|
||||
<div class="control-group">
|
||||
{% block extra_controls %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock controls %}
|
||||
|
||||
{% block tabs %}
|
||||
<ul class="nav nav-tabs px-3">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link active" role="tab">{% trans "Worker" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock tabs %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col col-md-12">
|
||||
<div class="card">
|
||||
<h5 class="card-header">{% trans "Worker" %}</h5>
|
||||
<div class="card-body">
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">{% trans "Name" %}</th>
|
||||
<td>{{ worker.name|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "State" %}</th>
|
||||
<td>{{ worker.get_state|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Birth" %}</th>
|
||||
<td>{{ worker.birth_date|annotated_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Queues" %}</th>
|
||||
<td>{{ queue_names|annotated_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "PID" %}</th>
|
||||
<td>{{ worker.pid|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Curent Job" %}</th>
|
||||
<td>{{ job.func_name|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Successful job count" %}</th>
|
||||
<td>{{ worker.successful_job_count|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Failed job count" %}</th>
|
||||
<td>{{ worker.failed_job_count }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Total working time (seconds)" %}</th>
|
||||
<td>{{ total_working_time }}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
Loading…
Reference in New Issue
Block a user