index-cls.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. 
  2. <!DOCTYPE html>
  3. <meta name="apple-mobile-web-app-capable" content="yes" />
  4. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=0.6, maximum-scale=0.6"/>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <script type='text/javascript' charset='utf-8'>
  9. // Hides mobile browser's address bar when page is done loading.
  10. window.addEventListener('load', function(e) {
  11. setTimeout(function() { window.scrollTo(0, 1); }, 1);
  12. }, false);
  13. </script>
  14. <title>ArOZ Onlineβ</title>
  15. <link rel="stylesheet" href="../../../script/tocas/tocas.css">
  16. <script src="../../../script/tocas/tocas.js"></script>
  17. <script src="../../../script/jquery.min.js"></script>
  18. </head>
  19. <body style="background-color: rgb(247, 247, 247);">
  20. <div class="ts container">
  21. <br>
  22. <div class="ts segment">
  23. <div class="ts header">
  24. Cluster Storage Manager
  25. <div class="sub header">
  26. Harddisk SMART
  27. </div>
  28. </div>
  29. </div>
  30. <div class="ts divider"></div>
  31. <div class="ts segment">
  32. <div class="ts items">
  33. <div class="item">
  34. <i id="MessageIcon" class="large inverted info rounded checkmark icon"></i>
  35. <div class="content">
  36. <div class="header" id="MessageHeader">Operating normal.</div>
  37. <div class="extra" id="MessageContent">
  38. System working.
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="ts fluid statistics">
  44. <div class="statistic">
  45. <div class="value" id="Cluster">0</div>
  46. <div class="label">Cluster online</div>
  47. </div>
  48. <div class="statistic">
  49. <div class="value" id="Installed">0</div>
  50. <div class="label">Disk installed</div>
  51. </div>
  52. <div class="statistic">
  53. <div class="value" id="Healthy">0</div>
  54. <div class="label">Disk healthy</div>
  55. </div>
  56. <div class="statistic">
  57. <div class="value" id="capacity">0 Byte</div>
  58. <div class="label">Total</div>
  59. </div>
  60. </div>
  61. <div class="ts divider"></div>
  62. <table class="ts very basic table">
  63. <thead>
  64. <tr>
  65. <th>IPs</th>
  66. <th>Model</th>
  67. <th>Mounted</th>
  68. <th>Capactiy</th>
  69. <th>SMART</th>
  70. </tr>
  71. </thead>
  72. <tbody id="SMARTtableBody">
  73. </tbody>
  74. </table>
  75. </div>
  76. <br>
  77. </div>
  78. <Script>
  79. var capacity = 0;
  80. var healthy = 0;
  81. var totalDisk = 0;
  82. var cluster = 0;
  83. var template = "<tr><td>%ip%</td><td>%model%</td><td>%mount%</td><td>%capacity%</td><td>%smart%</td></tr>";
  84. $.get( "../cluster/clusterList.config", function( raw ) {
  85. cluster = raw.split("\n").length - 1;
  86. $.each( raw.split("\n"), function( key, IP ) {
  87. if(IP !== ""){
  88. $.get( "fetchCluster.php?ip=" + IP + "&opr=scan", function( raw ) {
  89. var Maindata = JSON.parse(raw);
  90. $.each( Maindata["devices"], function( key, value ) {
  91. $.get( "fetchCluster.php?ip=" + IP + "&opr=info&drive=" + value["name"], function( raw ) {
  92. var DiskData = JSON.parse(raw);
  93. var tmp = template;
  94. var smart = "OK";
  95. if(typeof DiskData["ata_smart_attributes"] === 'undefined'){
  96. smart = "Unknown";
  97. healthy = healthy - 1;
  98. }else{
  99. var flag = false;
  100. $.each( DiskData["ata_smart_attributes"]["table"], function( key, value ) {
  101. if(value["when_failed"] !== "" && flag == false){
  102. smart = "Failed";
  103. healthy = healthy - 1;
  104. flag = true;
  105. $("#MessageIcon").attr("class","large inverted negative rounded remove icon");
  106. $("#MessageHeader").text("Warning");
  107. $("#MessageContent").text("One or more disk on cluster have SMART warning.");
  108. }
  109. });
  110. }
  111. tmp = tmp.replace("%ip%",IP);
  112. tmp = tmp.replace("%mount%",DiskData["device"]["info_name"]);
  113. tmp = tmp.replace("%model%",DiskData["model_name"]);
  114. tmp = tmp.replace("%capacity%",disksize(DiskData["user_capacity"]["bytes"]));
  115. tmp = tmp.replace("%smart%",smart);
  116. capacity = capacity + DiskData["user_capacity"]["bytes"];
  117. totalDisk = totalDisk + 1;
  118. healthy = healthy + 1;
  119. $("#Cluster").text(cluster);
  120. $("#Installed").text(totalDisk);
  121. $("#Healthy").text(healthy);
  122. $("#capacity").text(disksize(capacity));
  123. $("#SMARTtableBody").append(tmp);
  124. });
  125. });
  126. });
  127. }
  128. });
  129. });
  130. function disksize(size){
  131. if(size >= 1000000000000000){
  132. return Math.floor(size/1000000000000000*10)/10 + " PB";
  133. }else if(size >= 1000000000000){
  134. return Math.floor(size/1000000000000*10)/10 + " TB";
  135. }else if(size >= 1000000000){
  136. return Math.floor(size/1000000000*10)/10 + " GB";
  137. }else if(size >= 1000000){
  138. return Math.floor(size/1000000*10)/10 + " MB";
  139. }else if(size >= 1024){
  140. return Math.floor(size/1000*10)/10 + " KB";
  141. }else{
  142. return size + " Bytes";
  143. }
  144. }
  145. console.warn("%cSTOP!\n%cPlease beware not to copy and paste anything from the internet to this console as this might bring damage to your system.",'color: red;font-size: 76px','color: red');
  146. console.info(`%c ! ____ _____ ___ ____
  147. ! ! / ___|_ _/ _ \\| _ \\
  148. ! ! ! \\___ \\ | || | | | |_) |
  149. ! ! ! ___) || || |_| | __/
  150. ! ! ! |____/ |_| \\___/|_|
  151. ! ! !
  152. ! !
  153. ! ! !
  154. !!!!!!!!!!!!!!!!!!! `,'color: red;');
  155. </script>
  156. </body>
  157. </html>