Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions flower/static/js/flower.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,14 @@ var flower = (function () {
order: [
[1, "des"]
],
footerCallback: function( tfoot, data, start, end, display ) {
footerCallback: function(tfoot, data, start, end, display) {
var api = this.api();
var columns = {2:"STARTED", 3:"", 4:"FAILURE", 5:"SUCCESS", 6:"RETRY"};
var columns = {2:"", 3:"", 4:"STARTED", 5:"", 6:"FAILURE", 7:"SUCCESS", 8:"RETRY"};
for (const [column, state] of Object.entries(columns)) {
var total = api.column(column).data().reduce(sum, 0);
var footer = total;
if (total !== 0) {
let queryParams = (state !== '' ? `?state=${state}` : '');
footer = '<a href="' + url_prefix() + '/tasks' + queryParams + '">' + total + '</a>';
if (total !== 0 && state !== '') {
footer = '<a href="' + url_prefix() + '/tasks?state=' + state + '">' + total + '</a>';
}
$(api.column(column).footer()).html(footer);
}
Expand All @@ -476,37 +475,47 @@ var flower = (function () {
}
}
}, {
targets: 2,
targets: 2,
data: 'max_concurrency',
className: "text-center",
width: "10%",
}, {
targets: 3,
data: 'available_slots',
className: "text-center",
width: "10%",
}, {
targets: 4,
data: 'active',
className: "text-center",
width: "10%",
defaultContent: 0
}, {
targets: 3,
targets: 5,
data: 'task-received',
className: "text-center",
width: "10%",
defaultContent: 0
}, {
targets: 4,
targets: 6,
data: 'task-failed',
className: "text-center",
width: "10%",
defaultContent: 0
}, {
targets: 5,
targets: 7,
data: 'task-succeeded',
className: "text-center",
width: "10%",
defaultContent: 0
}, {
targets: 6,
targets: 8,
data: 'task-retried',
className: "text-center",
width: "10%",
defaultContent: 0
}, {
targets: 7,
targets: 9,
data: 'loadavg',
width: "10%",
className: "text-center text-nowrap",
Expand Down
6 changes: 6 additions & 0 deletions flower/templates/workers.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<tr>
<th>Worker</th>
<th class="text-center">Status</th>
<th class="text-center">Max Concurrencies</th>
<th class="text-center">Available</th>
<th class="text-center">Active</th>
<th class="text-center">Processed</th>
<th class="text-center">Failed</th>
Expand All @@ -24,6 +26,8 @@
{% for name, info in workers.items() %}
<tr id="{{ url_escape(name) }}">
<td>{{ name }}</td>
<td>{{ info.get('stats', {}).get('pool', {}).get('max_concurrency', 0) }}</td>
<td>{{ info.get('stats', {}).get('pool', {}).get('available_slots', 0) }}</td>
<td>{{ info.get('status', None) }}</td>
<td>{{ info.get('active', 0) or 0 }}</td>
<td>{{ info.get('task-received', 0) }}</td>
Expand All @@ -44,6 +48,8 @@
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
Expand Down
17 changes: 17 additions & 0 deletions flower/views/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,25 @@ async def get(self):
info = dict(values)
info.update(self._as_dict(worker))
info.update(status=worker.alive)

try:
worker_data = self.application.workers.get(name, {})
worker_stats = worker_data.get('stats', {})
max_concurrency = worker_stats.get('pool', {}).get('max-concurrency', 0)
active = info.get('active', 0) or 0

available_slots = max(0, max_concurrency - active)

info['max_concurrency'] = max_concurrency
info['available_slots'] = available_slots

logger.info(f"[Flower] {name} max concurrency = {max_concurrency}")
except Exception as e:
logger.warning(f"Failed to get max concurrency for {name}: {e}")

workers[name] = info


if options.purge_offline_workers is not None:
timestamp = int(time.time())
offline_workers = []
Expand Down