PageRenderTime 44ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/core/web/modules/base/status/index.php

https://github.com/vmasilva/mmc
PHP | 229 lines | 165 code | 37 blank | 27 comment | 15 complexity | 3ed531599a3b653b2a7513b61ca577dd MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * (c) 2004-2007 Linbox / Free&ALter Soft, http://linbox.com
  4. * (c) 2007-2008 Mandriva, http://www.mandriva.com
  5. *
  6. * $Id$
  7. *
  8. * This file is part of Mandriva Management Console (MMC).
  9. *
  10. * MMC is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * MMC is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with MMC; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. ?>
  25. <?
  26. /* dĂŠfinition des fonctions pour cette page */
  27. function print_mem_bar($title, $max, $used, $cache = 0, $width = 320) {
  28. $wused = ($used / $max) * $width;
  29. if ($title != "") {
  30. echo $title." :";
  31. }
  32. echo "<div class=\"membarfree\" style=\"width: ".$width."px\">";
  33. if ($cache > 0) {
  34. printf("<div class=\"membarcache\" style=\"width: %.0fpx\">", $wused);
  35. $wused = (($used - $cache) / $max) * $width;
  36. }
  37. printf("<div class=\"membarused\" style=\"width: %.0fpx\"></div>", $wused);
  38. if ($cache > 0) {
  39. echo "</div>";
  40. }
  41. echo "</div>\n";
  42. }
  43. function print_disk_info() {
  44. /* -l option to only get local filesystem occupation */
  45. $df = xmlCall("base.getDisksInfos");
  46. unset($df[0]);
  47. echo "<table>";
  48. $incomplete_lines = "";
  49. foreach ($df as $disk) {
  50. //if previous is truncated we add it to the current line
  51. if ($incomplete_lines) {
  52. $disk = $incomplete_lines ." ". $disk;
  53. unset($incomplete_lines);
  54. }
  55. if (preg_match("/^\/dev\/mapper\/data-snap/", $disk)
  56. || preg_match("/^[ ]+/", $disk)) {
  57. continue;
  58. }
  59. //if device name use whole line... we skip this line
  60. //concatenate it with the next
  61. if (!preg_match(("/[ ]/"),$disk)) {
  62. $incomplete_lines = $disk;
  63. continue;
  64. }
  65. $disk = preg_split("/[ ]+/", $disk);
  66. if ((array_search($disk[0], array("tmpfs", "none", "udev"))!==FALSE) || ($disk[1] == "0"))
  67. continue;
  68. echo "<tr><td class=\"statusPad\">$disk[5]</td><td class=\"statusPad\">($disk[0])</td><td class=\"statusPad\">[$disk[4]]</td></tr>\n";
  69. echo "<tr><td colspan=\"3\" class=\"statusPad\" style=\"padding-bottom: 2px;\">";
  70. print_mem_bar("", $disk[1], $disk[2]);
  71. echo "</td></tr>\n";
  72. }
  73. echo "</table>";
  74. }
  75. function print_health() {
  76. $up = xmlCall("base.getUptime");
  77. $up = trim($up);
  78. list($up) = explode(" ", $up);
  79. $days = (int) ($up / (24*60*60));
  80. $up -= $days * 24*60*60;
  81. $hrs = (int)($up / (60*60));
  82. $up -= $hrs * 60*60;
  83. $mins = (int)($up / 60);
  84. ($days > 1) ? $d = "s" : $d = "";
  85. ($hrs > 1) ? $h = "s" : $h = "";
  86. ($mins > 1) ? $m = "s" : $m = "";
  87. echo _("Uptime: ");
  88. if ($days > 0) {
  89. echo $days." "._("day").$d." ";
  90. }
  91. if (($days > 0) || ($hrs > 0)) {
  92. echo $hrs." "._("hour").$h." ";
  93. }
  94. echo $mins." "._("minute").$m."<br/><br/>\n";
  95. $mem = xmlCall("base.getMemoryInfos");
  96. $m = preg_split("/[ ]+/", $mem[1]);
  97. print_mem_bar(_("Memory"), $m[1], $m[2],$m[5]+$m[6]);
  98. $m = preg_split("/[ ]+/", $mem[3]);
  99. if ($m[1] > 0) {
  100. print_mem_bar(_("Swap"), $m[1], $m[2]);
  101. }
  102. }
  103. function print_ldap_conf() {
  104. $conf = xmlCall("base.getLdapRootDN",null);
  105. foreach($conf as $name => $value) {
  106. echo '<p>'.$name.' : '.$value.'</p>';
  107. }
  108. }
  109. ?>
  110. <style type="text/css">
  111. <!--
  112. div.membarfree {
  113. border-right: 1px solid #27537C;
  114. height: 12px;
  115. background: url("<?php echo $root; ?>img/main/bg_status_blue.gif") repeat-x left top transparent;
  116. padding: 0;
  117. margin: 0;
  118. }
  119. div.membarused {
  120. border: none;
  121. background: red;
  122. height: 12px;
  123. background: url("<?php echo $root; ?>img/main/bg_status_orange.gif") repeat-x right top transparent;
  124. overflow: hidden;
  125. float: left;
  126. padding: 0;
  127. display: inline;
  128. }
  129. div.membarcache {
  130. height: 12px;
  131. background: url("<?php echo $root; ?>img/main/bg_status_green.gif") repeat-x right top transparent;
  132. float: left;
  133. padding: 0;
  134. margin: 0;
  135. }
  136. *html div.membarused { margin: 0 -4px 0 0; } /* pour IE/PC */
  137. *html div.membarcache { margin: 0 -4px 0 0; } /* pour IE/PC */
  138. div.right {
  139. float: right;
  140. width: 49%;
  141. margin: 0;
  142. }
  143. div.left {
  144. width: 49%;
  145. margin: 0;
  146. }
  147. h2.statusPad {
  148. text-align: center;
  149. }
  150. div.statusPad {
  151. padding: 0px;
  152. text-align: center;
  153. font-size: 11px;
  154. color: #666;
  155. background-color: #F0F4F7;
  156. border: solid 1px #CCC;
  157. -moz-border-radius: 1em;
  158. -webkit-border-radius: 1em;
  159. padding: 10px;
  160. margin-bottom: 10px;
  161. }
  162. -->
  163. </style>
  164. <?php
  165. require("graph/navbar.inc.php");
  166. require("includes/statusSidebar.inc.php");
  167. $p = new PageGenerator(_("Global view"));
  168. $p->displayTitle();
  169. ?>
  170. <div class="right">
  171. <div class="statusPad">
  172. <h2 class="statusPad"><?php echo _("Server status") ?></h2>
  173. <?php print_health(); ?>
  174. </div>
  175. <div class="statusPad">
  176. <h2 class="statusPad"><?php echo _("LDAP Configuration") ?></h2>
  177. <?php print_ldap_conf(); ?>
  178. </div>
  179. </div>
  180. <div class="left">
  181. <div class="statusPad">
  182. <h2 class="statusPad"><?php echo _("Hard drive partitions") ?></h2>
  183. <?php print_disk_info(); ?>
  184. </div>
  185. <div class="statusPad">
  186. <h2 class="statusPad"><?php echo _("Background jobs") ?></h2>
  187. <div id="bgps"> </div>
  188. <script type="text/javascript">
  189. new Ajax.PeriodicalUpdater('bgps','includes/bgps_view.php', {asynchronous: true, frequency: 2});
  190. </script>
  191. </div>
  192. </div>