{# Glances resource stats display #} {% from "partials/icons.html" import cpu, memory_stick, gauge, server, activity, hard_drive, arrow_down_up, refresh_cw %} {% macro progress_bar(percent, color="primary") %}
{{ "%.1f"|format(percent) }}%
{% endmacro %} {% macro format_rate(bytes_per_sec) %} {%- if bytes_per_sec >= 1048576 -%} {{ "%.1f"|format(bytes_per_sec / 1048576) }} MB/s {%- elif bytes_per_sec >= 1024 -%} {{ "%.1f"|format(bytes_per_sec / 1024) }} KB/s {%- else -%} {{ "%.0f"|format(bytes_per_sec) }} B/s {%- endif -%} {% endmacro %} {% macro host_row(host_stats) %} {{ server(14) }} {{ host_stats.host }} {% if host_stats.error %} {{ host_stats.error }} {% else %} {{ progress_bar(host_stats.cpu_percent, "info") }} {{ progress_bar(host_stats.mem_percent, "success") }} {{ progress_bar(host_stats.disk_percent, "warning") }} ↓{{ format_rate(host_stats.net_rx_rate) }} ↑{{ format_rate(host_stats.net_tx_rate) }} {{ "%.1f"|format(host_stats.load) }} {% endif %} {% endmacro %}

{{ activity(18) }} Host Resources

{% for host_name, host_stats in stats.items() %} {{ host_row(host_stats) }} {% endfor %}
Host {{ cpu(14) }} CPU {{ memory_stick(14) }} Memory {{ hard_drive(14) }} Disk {{ arrow_down_up(14) }} Net {{ gauge(14) }} Load