hosts_show.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {% extends "layout.html" %}
  2. {% block head %}
  3. {{ super() }}
  4. {% endblock head %}
  5. {% block content %}
  6. <script type="text/javascript">
  7. var page = 1;
  8. var page_size = 10;
  9. var keyword = '';
  10. var resource_path = window.location.pathname;
  11. var cur_url = resource_path;
  12. $(document).ready(function() {
  13. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  14. var last_ready = null;
  15. $('#content_search').keydown(function() {
  16. if (last_ready !== null) {
  17. clearTimeout(last_ready);
  18. }
  19. last_ready = setTimeout(function () {
  20. keyword = $('#content_search').val();
  21. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  22. if (keyword.length > 0) {
  23. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  24. }
  25. window.location.href=cur_url;
  26. }, 1000);
  27. });
  28. $('body').addClass('add-transition');
  29. $('.add-page-transition').on('click', function(){
  30. var transAttr = $(this).attr('data-transition');
  31. $('.add-transition').attr('class', 'add-transition');
  32. $('.add-transition').addClass(transAttr);
  33. });
  34. });
  35. function refresh() {
  36. keyword = $('#content_search').val();
  37. page = $('#pagination li.active a').text();
  38. page_size = $('#page_size').val();
  39. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size;
  40. if (keyword.length > 0) {
  41. cur_url = resource_path + '?page=' + page + '&page_size=' + page_size + '&keyword=' + keyword;
  42. }
  43. window.location.href=cur_url;
  44. }
  45. </script>
  46. <div class="panel">
  47. <div class="panel-body">
  48. <h3 class="title-hero" style="font-size: 24px;">
  49. 宿主机
  50. </h3>
  51. <div>
  52. <div id="datatable-row-highlight_wrapper" class="dataTables_wrapper form-inline">
  53. <div class="row" style="padding: 10px 10px 10px 0; width: 100%;">
  54. <div class="col-sm-12" style="padding-right: 0;">
  55. <div id="datatable-row-highlight_filter" class="dataTables_filter" style="display: inline-block;">
  56. <input id="content_search" type="search" class="form-control" placeholder="模糊搜索..." value="{%- if keyword -%} {{ keyword }} {%- endif -%}" style="margin-left: 0; border-radius: 0;">
  57. </div>
  58. <div class="pull-right">
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="row">
  64. {% for item in hosts_ret.data %}
  65. <div class="col-md-4">
  66. <div class="host-box content-box">
  67. <h3 class="bg-black host-title">{{ item.hostname }}</h3>
  68. <div class="bg-blue host-specs">
  69. <span>{{ '%0.2f'| format(item.system_load[0] / item.cpu | round) }}</span>
  70. <i>当前系统负载</i>
  71. </div>
  72. <div class="bg-orange host-specs">
  73. <span>{{(((item.memory - item.memory_available) / item.memory | round) * 100) | int}}%</span>
  74. <i>内存使用率</i>
  75. </div>
  76. <ul>
  77. <li>CPU: {{ item.cpu }} 核</li>
  78. <li>内存: {{ (item.memory / 1024 / 1024 / 1024)|int }} GB</li>
  79. <!--<li><i class="glyph-icon icon-circle font-size-23 {% if item.alive == true %}font-green{% else %}font-red{% endif %}"></i></li>-->
  80. {% for nic_name, nic in item.interfaces.iteritems() %}
  81. <li>网卡: {{ nic_name }} | IP: {{ nic.ip }}</li>
  82. {% endfor %}
  83. {% for mountpoint, disk in item.disks.iteritems() %}
  84. <li>挂载点: {{ mountpoint }} | {{ (disk.total / 1024 / 1024 / 1024) | int }} GB | 使用率: {{ disk.percent }}%</li>
  85. {% endfor %}
  86. </ul>
  87. </div>
  88. </div>
  89. {% endfor %}
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. {% endblock content %}