Collect partition info and unify storage table with disk, partition, and usage data
This commit is contained in:
@@ -296,21 +296,67 @@
|
||||
<div class="detail-section wide">
|
||||
<h4>Storage</h4>
|
||||
{% set disks = d.get('disk', []) if d.get('disk') else [] %}
|
||||
{% set partitions = d.get('partition', []) if d.get('partition') else [] %}
|
||||
{% if disks %}
|
||||
<table>
|
||||
<tr class="table-header"><td>Device</td><td>Size</td></tr>
|
||||
<tr class="table-header"><td>Device</td><td>Mount</td><td>Size</td><td>Used</td><td>Avail</td><td>Use%</td></tr>
|
||||
{% for disk in disks %}
|
||||
<tr>
|
||||
<td>{{ disk.get('name', '-') }}</td>
|
||||
<td><strong>{{ disk.get('name', '-') }}</strong></td>
|
||||
<td></td>
|
||||
<td>{{ disk.get('size_bytes', '')|format_bytes }}</td>
|
||||
<td></td><td></td><td></td>
|
||||
</tr>
|
||||
{% for part in partitions if part.get('parent') == disk.get('name') %}
|
||||
{% set part_mount = part.get('mount', '') %}
|
||||
{% set ns = namespace(du=none) %}
|
||||
{% for du in disk_usages if du.get('mount') == part_mount and part_mount %}
|
||||
{% set ns.du = du %}
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td style="padding-left: 20px;">{{ part.get('name', '-') }}</td>
|
||||
<td>{{ part_mount or '-' }}</td>
|
||||
<td>{{ part.get('size_bytes', '')|format_bytes }}</td>
|
||||
{% if ns.du %}
|
||||
<td>{{ ns.du.get('used_bytes', '')|format_bytes }}</td>
|
||||
<td>{{ ns.du.get('available_bytes', '')|format_bytes }}</td>
|
||||
<td>
|
||||
<span class="disk-pct" style="color: {{ ns.du.get('usage_percent', '0')|float|usage_color }}">
|
||||
{{ ns.du.get('usage_percent', '-') }}%
|
||||
</span>
|
||||
</td>
|
||||
{% else %}
|
||||
<td></td><td></td><td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{# Show any disk_usage entries not matched to a partition (e.g. NFS, LVM, ZFS) #}
|
||||
{% for du in disk_usages %}
|
||||
{% set ns = namespace(matched=false) %}
|
||||
{% for part in partitions if part.get('mount') == du.get('mount') and part.get('mount') %}
|
||||
{% set ns.matched = true %}
|
||||
{% endfor %}
|
||||
{% if not ns.matched %}
|
||||
<tr>
|
||||
<td>{{ du.get('mount', '-') }}</td>
|
||||
<td>{{ du.get('mount', '-') }}</td>
|
||||
<td>{{ du.get('total_bytes', '')|format_bytes }}</td>
|
||||
<td>{{ du.get('used_bytes', '')|format_bytes }}</td>
|
||||
<td>{{ du.get('available_bytes', '')|format_bytes }}</td>
|
||||
<td>
|
||||
<span class="disk-pct" style="color: {{ du.get('usage_percent', '0')|float|usage_color }}">
|
||||
{{ du.get('usage_percent', '-') }}%
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% if disk_usages %}
|
||||
<table style="margin-top: 8px;">
|
||||
<tr class="table-header"><td>Mount</td><td>Total</td><td>Used</td><td>Available</td><td>Usage</td></tr>
|
||||
{% elif disk_usages %}
|
||||
{# Fallback: no lsblk data (e.g. containers), just show df data #}
|
||||
<table>
|
||||
<tr class="table-header"><td>Mount</td><td>Total</td><td>Used</td><td>Avail</td><td>Use%</td></tr>
|
||||
{% for du in disk_usages %}
|
||||
<tr>
|
||||
<td>{{ du.get('mount', '-') }}</td>
|
||||
|
||||
Reference in New Issue
Block a user