Explorar el Código

完成宿主机列表页

James Iter hace 9 años
padre
commit
90e12e7bec
Se han modificado 2 ficheros con 17 adiciones y 17 borrados
  1. 2 0
      models/event_processor.py
  2. 15 17
      templates/hosts_show.html

+ 2 - 0
models/event_processor.py

@@ -106,7 +106,9 @@ class EventProcessor(object):
         value = {
             'hostname': cls.message['host'],
             'cpu': cls.message['message']['cpu'],
+            'system_load': cls.message['message']['system_load'],
             'memory': cls.message['message']['memory'],
+            'memory_available': cls.message['message']['memory_available'],
             'interfaces': cls.message['message']['interfaces'],
             'disks': cls.message['message']['disks'],
             'timestamp': ji.Common.ts()

+ 15 - 17
templates/hosts_show.html

@@ -12,7 +12,6 @@
     var cur_url = resource_path;
 
     $(document).ready(function() {
-        page_size = $('#page_size').val();
         cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
 
         var last_ready = null;
@@ -30,16 +29,6 @@
             }, 1000);
         });
 
-        $('#page_size').change(function () {
-            keyword = $('#content_search').val();
-            page_size = $('#page_size').val();
-            cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
-            if (keyword.length > 0) {
-                cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
-            }
-            window.location.href=cur_url;
-        });
-
         $('body').addClass('add-transition');
         $('.add-page-transition').on('click', function(){
             var transAttr = $(this).attr('data-transition');
@@ -73,7 +62,6 @@
                                 <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
                             </div>
                             <div class="pull-right">
-                                <button class="btn btn-default" onclick="refresh()" style="border-radius: 0;"><span class="glyph-icon icon-elusive-arrows-cw"></span></button>
                             </div>
                         </div>
                     </div>
@@ -84,13 +72,23 @@
                         <div class="host-box content-box">
                             <h3 class="bg-black host-title">{{ item.hostname }}</h3>
                             <div class="bg-blue host-specs">
-                                <span><sup>$</sup>1.5</span>
-                                <i>当前负载</i>
+                                <span>{{ '%0.2f'| format(item.system_load[0] / item.cpu | round) }}</span>
+                                <i>当前系统负载</i>
+                            </div>
+                            <div class="bg-orange host-specs">
+                                <span>{{(((item.memory - item.memory_available) / item.memory | round) * 100) | int}}%</span>
+                                <i>内存使用率</i>
                             </div>
                             <ul>
-                                <li>CPU: {{ item.cpu }}核</li>
-                                <li>内存: {{ item.memory / 1024 / 1024 / 1024 }}</li>
-                                <li><i class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i></li>
+                                <li>CPU: {{ item.cpu }} 核</li>
+                                <li>内存: {{ (item.memory / 1024 / 1024 / 1024)|int }} GB</li>
+                                <!--<li><i class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i></li>-->
+                                {% for nic_name, nic in item.interfaces.iteritems() %}
+                                    <li>网卡: {{ nic_name }} | IP: {{ nic.ip }}</li>
+                                {% endfor %}
+                                {% for mountpoint, disk in item.disks.iteritems() %}
+                                    <li>挂载点: {{ mountpoint }} | {{ (disk.total / 1024 / 1024 / 1024) | int }} GB | 使用率: {{ disk.percent }}%</li>
+                                {% endfor %}
                             </ul>
                         </div>
                     </div>