Просмотр исходного кода

加入Guest 网络流量top 10展现

James Iter 9 лет назад
Родитель
Сommit
59988c4c81
2 измененных файлов с 43 добавлено и 2 удалено
  1. 41 0
      templates/dashboard.html
  2. 2 2
      templates/hosts_show.html

+ 41 - 0
templates/dashboard.html

@@ -140,6 +140,47 @@
                         </div>
                     </div>
                 </div>
+                <div class="col-md-4">
+                    <div class="content-box">
+                        <h3 class="content-box-header bg-green">
+                            网络流量
+                        </h3>
+                        <div class="content-box-wrapper" style="padding-top: 0;">
+                            <table class="table mrg0B mrg10T">
+                                <thead>
+                                <tr>
+                                    <td style="width: 65%;">实例</td>
+                                    <td>流量</td>
+                                </tr>
+                                </thead>
+                                <tbody>
+                                {% for item in guests_current_top_10_ret.data.rt_bytes %}
+                                    {% if item.guest_uuid not in guests_mapping_by_uuid %}{% continue %}{% endif %}
+                                    <tr>
+                                        <td class="text-left">
+                                            <a href="/guest/detail/{{ item.guest_uuid }}">
+                                                {{ guests_mapping_by_uuid[item.guest_uuid].label }}/{{ guests_mapping_by_uuid[item.guest_uuid].remark }}
+                                            </a>
+                                        </td>
+                                        <td>
+                                            <!-- 速率参考链接:https://en.wikipedia.org/wiki/Data_rate_units#Examples_of_bit_rates -->
+                                            {% if item.rt_bytes * 8 >= 1000**3 %}
+                                                {{ '%0.1f'| format(item.rt_bytes * 8 / 1000**3) }} Gbps
+                                            {% elif item.rt_bytes * 8 >= 1000**2 %}
+                                                {{ '%0.1f'| format(item.rt_bytes * 8 / 1000**2) }} Mbps
+                                            {% elif item.rt_bytes * 8 >= 1000 %}
+                                                {{ '%0.1f'| format(item.rt_bytes * 8 / 1000) }} kbps
+                                            {% else %}
+                                                {{ item.rt_bytes * 8 }} bps
+                                            {% endif %}
+                                        </td>
+                                    </tr>
+                                {% endfor %}
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                </div>
             </div>
         </div>
     </div>

+ 2 - 2
templates/hosts_show.html

@@ -84,11 +84,11 @@
                                 <div class="show_detail_link" style="display: none; position: absolute; z-index: 9999; margin-left: 246px; margin-top: 20px;">
                                     <a href="/host/detail/{{ item.node_id }}" style="color: white; background-color: black;">&nbsp;&nbsp;&nbsp;&nbsp;主机详情&nbsp;&nbsp;&nbsp;&nbsp;</a>
                                 </div>
-                                <span>{{ '%0.2f'| format(item.system_load[0] / item.cpu | round) }}</span>
+                                <span>{{ '%0.2f'| format(item.system_load[0] / item.cpu) }}</span>
                                 <i>当前系统负载</i>
                             </div>
                             <div class="bg-orange host-specs">
-                                <span>{{(((item.memory - item.memory_available) / item.memory | round) * 100) | int}}%</span>
+                                <span>{{(((item.memory - item.memory_available) / item.memory) * 100) | int}}%</span>
                                 <i>内存使用率</i>
                             </div>
                             <ul>