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

实现 JimV-N 功能线程状态的展现

James Iter 8 лет назад
Родитель
Сommit
146ac56168
3 измененных файлов с 97 добавлено и 8 удалено
  1. 1 1
      docs/todo.md
  2. 42 1
      models/host.py
  3. 54 6
      templates/host_detail.html

+ 1 - 1
docs/todo.md

@@ -61,7 +61,7 @@
 - [ ] 迁移时计算出剩余时间
 - [ ] 初始化页面检测 redis、mysql 是否准备好
 - [ ] 日志里面加入操作轨迹
-- [ ] 计算节点页面,展现每个计算节点上功能线程的状态
+- [x] 计算节点页面,展现每个计算节点上功能线程的状态
 - [x] 避免计算节点主机名相同的情况
 - [ ] 考虑 vm_network,vm_manage_network 改名为 vm_network_bridge,vm_manage_network_bridge
 - [ ] 通过 sysctl 隔离出 vnc 使用的端口,避免被冲突。参见 net.ipv4.ip_local_reserved_ports

+ 42 - 1
models/host.py

@@ -26,13 +26,54 @@ class Host(object):
         JimV-C 2 秒更新一次宿主机信息,这里以 5 秒内没收到更新,作为判断宿主机是否在线的标准
         """
 
+        coupler_length = 5
+
         if 'timestamp' not in v:
             return v
 
         v['alive'] = False
-        if v['timestamp'] + 5 >= g.ts:
+        if v['timestamp'] + coupler_length >= g.ts:
             v['alive'] = True
 
+        if 'threads_status' not in v:
+            v['threads_status'] = {
+                'instruction_process_engine': {
+                    'timestamp': 0,
+                    'alive': False
+                },
+                'host_state_report_engine': {
+                    'timestamp': 0,
+                    'alive': False
+                },
+                'guest_creating_progress_report_engine': {
+                    'timestamp': 0,
+                    'alive': False
+                },
+                'guest_performance_collection_engine': {
+                    'timestamp': 0,
+                    'alive': False
+                },
+                'host_performance_collection_engine': {
+                    'timestamp': 0,
+                    'alive': False
+                }
+            }
+
+        if v['threads_status']['instruction_process_engine']['timestamp'] + coupler_length >= g.ts:
+            v['threads_status']['instruction_process_engine']['alive'] = True
+
+        if v['threads_status']['host_state_report_engine']['timestamp'] + coupler_length >= g.ts:
+            v['threads_status']['host_state_report_engine']['alive'] = True
+
+        if v['threads_status']['guest_creating_progress_report_engine']['timestamp'] + coupler_length >= g.ts:
+            v['threads_status']['guest_creating_progress_report_engine']['alive'] = True
+
+        if v['threads_status']['guest_performance_collection_engine']['timestamp'] + coupler_length >= g.ts:
+            v['threads_status']['guest_performance_collection_engine']['alive'] = True
+
+        if v['threads_status']['host_performance_collection_engine']['timestamp'] + coupler_length >= g.ts:
+            v['threads_status']['host_performance_collection_engine']['alive'] = True
+
         return v
 
     @staticmethod

+ 54 - 6
templates/host_detail.html

@@ -934,11 +934,51 @@
                             </td>
                         </tr>
                         <tr>
-                            <td>
-                                <span class="guest-label">状态:&nbsp;&nbsp;&nbsp;&nbsp;</span>
-                                <span class="guest-desc">
-                                    <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.alive == true %}font-green{% else %}font-red{% endif %}"></i>
-                                </span>
+                            <td style="padding: 0;">
+                                <table style="width: 100%;">
+                                    <tr>
+                                        <td>
+                                            <span class="guest-label">节点健康状况:&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                            <span class="guest-desc">
+                                                <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.alive == true %}font-green{% else %}font-red{% endif %}"></i>
+                                            </span>
+                                        </td>
+                                        <td>
+                                            <span class="guest-label">节点性能收集引擎:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                            <span class="guest-desc">
+                                                <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.host_performance_collection_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
+                                            </span>
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <td>
+                                            <span class="guest-label">状态汇送引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                            <span class="guest-desc">
+                                                <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.host_state_report_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
+                                            </span>
+                                        </td>
+                                        <td>
+                                            <span class="guest-label">虚拟机性能收集引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                            <span class="guest-desc">
+                                                <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.guest_performance_collection_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
+                                            </span>
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <td>
+                                            <span class="guest-label">指令处理引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                            <span class="guest-desc">
+                                                <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.instruction_process_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
+                                            </span>
+                                        </td>
+                                        <td>
+                                            <span class="guest-label">虚拟机创建进度引擎:&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                            <span class="guest-desc">
+                                                <i class="glyph-icon icon-circle font-size-14 {% if host_ret.data.threads_status.guest_creating_progress_report_engine.alive == true %}font-green{% else %}font-red{% endif %}"></i>
+                                            </span>
+                                        </td>
+                                    </tr>
+                                </table>
                             </td>
                         </tr>
                         <tr>
@@ -980,7 +1020,15 @@
                         {% endfor %}
                         <tr>
                             <td>
-                                <span class="guest-label">数据更新时间:&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                <span class="guest-label">启动时间:&nbsp;&nbsp;&nbsp;&nbsp;</span>
+                                <span class="guest-desc">
+                                {{ format_datetime_by_tus(host_ret.data.boot_time * 1000 * 1000) }}
+                                </span>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td>
+                                <span class="guest-label">更新时间:&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                 <span class="guest-desc">
                                 {{ format_datetime_by_tus(host_ret.data.timestamp * 1000 * 1000) }}
                                 </span>