list_services.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a href="/edit/server/" class="button button-secondary">
  6. <i class="fas fa-gear icon-maroon"></i><?= tohtml( _("Configure")) ?>
  7. </a>
  8. <a href="/list/rrd/" class="button button-secondary">
  9. <i class="fas fa-chart-area icon-blue"></i><?= tohtml( _("Task Monitor")) ?>
  10. </a>
  11. <a href="/list/updates/" class="button button-secondary">
  12. <i class="fas fa-arrows-rotate icon-green"></i><?= tohtml( _("Updates")) ?>
  13. </a>
  14. <?php if (!empty($_SESSION["FIREWALL_SYSTEM"]) && $_SESSION["FIREWALL_SYSTEM"] == "iptables") { ?>
  15. <a href="/list/firewall/" class="button button-secondary">
  16. <i class="fas fa-shield-halved icon-red"></i><?= tohtml( _("Firewall")) ?>
  17. </a>
  18. <?php } ?>
  19. <a href="/list/log/?<?= tohtml(http_build_query(["user" => 'system', "token" => $_SESSION["token"]])) ?>" class="button button-secondary">
  20. <i class="fas fa-binoculars icon-orange"></i><?= tohtml( _("Logs")) ?>
  21. </a>
  22. <a
  23. class="button button-secondary button-danger data-controls js-confirm-action"
  24. href="/restart/system/?<?= tohtml(http_build_query(["hostname" => $sys["sysinfo"]["HOSTNAME"], "token" => $_SESSION["token"], "system_reset_token" => time()])) ?>"
  25. data-confirm-title="<?= tohtml( _("Restart")) ?>"
  26. data-confirm-message="<?= tohtml( _("Are you sure you want to restart the server?")) ?>"
  27. >
  28. <i class="fas fa-arrow-rotate-left icon-red"></i><?= tohtml( _("Restart")) ?>
  29. </a>
  30. </div>
  31. <div class="toolbar-right">
  32. <form x-data x-bind="BulkEdit" action="/bulk/service/" method="post">
  33. <input type="hidden" name="token" value="<?= tohtml($_SESSION["token"]) ?>">
  34. <select class="form-select" name="action">
  35. <option value=""><?= tohtml( _("Apply to selected")) ?></option>
  36. <option value="stop"><?= tohtml( _("Stop")) ?></option>
  37. <option value="start"><?= tohtml( _("Start")) ?></option>
  38. <option value="restart"><?= tohtml( _("Restart")) ?></option>
  39. </select>
  40. <button type="submit" class="toolbar-input-submit" title="<?= tohtml( _("Apply to selected")) ?>">
  41. <i class="fas fa-arrow-right"></i>
  42. </button>
  43. </form>
  44. </div>
  45. </div>
  46. </div>
  47. <!-- End toolbar -->
  48. <div class="container">
  49. <div class="server-summary">
  50. <div class="server-summary-icon">
  51. <i class="fas fa-server"></i>
  52. </div>
  53. <div class="server-summary-content">
  54. <h1 class="server-summary-title"><?= tohtml($sys["sysinfo"]["HOSTNAME"]) ?></h1>
  55. <ul class="server-summary-list">
  56. <li class="server-summary-item">
  57. <span class="server-summary-list-label">Hestia Control Panel</span>
  58. <span class="server-summary-list-value">
  59. <?php if ($sys["sysinfo"]["RELEASE"] == "release") { ?>
  60. <i class="fas fa-cube" title="<?= tohtml( _("Production Release")) ?>"></i>
  61. <?php } else { ?>
  62. <i class="fas fa-flask icon-red" title="<?= tohtml($sys["sysinfo"]["RELEASE"]) ?>"></i>
  63. <?php } ?>
  64. v<?= tohtml($sys["sysinfo"]["HESTIA"]) ?>
  65. </span>
  66. </li>
  67. <li class="server-summary-item">
  68. <span class="server-summary-list-label"><?= tohtml( _("Operating System")) ?></span>
  69. <span class="server-summary-list-value">
  70. <?= tohtml($sys["sysinfo"]["OS"]) ?> <?= tohtml($sys["sysinfo"]["VERSION"]) ?> (<?= tohtml($sys["sysinfo"]["ARCH"]) ?>)
  71. </span>
  72. </li>
  73. <li class="server-summary-item">
  74. <span class="server-summary-list-label"><?= tohtml( _("Load Average")) ?> <span class="hint">(1m / 5m / 15m)</span></span>
  75. <span class="server-summary-list-value">
  76. <?= tohtml($sys["sysinfo"]["LOADAVERAGE"]) ?>
  77. </span>
  78. </li>
  79. <li class="server-summary-item">
  80. <span class="server-summary-list-label"><?= tohtml( _("Uptime")) ?></span>
  81. <span class="server-summary-list-value">
  82. <?= tohtml(humanize_time($sys["sysinfo"]["UPTIME"])) ?>
  83. </span>
  84. </li>
  85. </ul>
  86. </div>
  87. </div>
  88. <h1 class="u-text-center u-hide-desktop u-pr30 u-mb20 u-pl30"><?= tohtml( _("Services")) ?></h1>
  89. <div class="units-table js-units-container">
  90. <div class="units-table-header">
  91. <div class="units-table-cell">
  92. <input type="checkbox" class="js-toggle-all-checkbox" title="<?= tohtml( _("Select all")) ?>">
  93. </div>
  94. <div class="units-table-cell"><?= tohtml( _("Service")) ?></div>
  95. <div class="units-table-cell"></div>
  96. <div class="units-table-cell"><?= tohtml( _("Description")) ?></div>
  97. <div class="units-table-cell u-text-center"><?= tohtml( _("Uptime")) ?></div>
  98. <div class="units-table-cell u-text-center"><?= tohtml( _("CPU")) ?></div>
  99. <div class="units-table-cell u-text-center"><?= tohtml( _("Memory")) ?></div>
  100. </div>
  101. <!-- Begin services status list item loop -->
  102. <?php
  103. foreach ($data as $key => $value) {
  104. ++$i;
  105. if ($data[$key]['STATE'] == 'running') {
  106. $status = 'active';
  107. $action = 'stop';
  108. $action_text = _('Stop');
  109. $spnd_icon = 'fa-stop';
  110. $spnd_icon_class = 'icon-red';
  111. $state_icon = 'fa-circle-check icon-green';
  112. } else {
  113. $status = 'suspended';
  114. $action = 'start';
  115. $action_text = _('Start');
  116. $spnd_icon = 'fa-play';
  117. $spnd_icon_class = 'icon-green';
  118. $state_icon = 'fa-circle-minus icon-red';
  119. }
  120. if (in_array($key, $phpfpm)){
  121. $edit_url="php";
  122. } else {
  123. $edit_url=$key;
  124. }
  125. $cpu = $data[$key]['CPU'] / 10;
  126. $cpu = number_format($cpu, 1);
  127. if ($cpu == '0.0') $cpu = 0;
  128. ?>
  129. <div class="units-table-row <?php if ($status == 'suspended') echo 'disabled'; ?> js-unit"
  130. data-sort-name="<?= tohtml(strtolower($key)) ?>"
  131. data-sort-memory="<?= tohtml($data[$key]["MEM"]) ?>"
  132. data-sort-cpu="<?= tohtml($cpu) ?>"
  133. data-sort-uptime="<?= tohtml($data[$key]["RTIME"]) ?>">
  134. <div class="units-table-cell">
  135. <div>
  136. <input id="check<?= tohtml($i) ?>" class="js-unit-checkbox" type="checkbox" title="<?= tohtml( _("Select")) ?>" name="service[]" value="<?= tohtml($key) ?>">
  137. <label for="check<?= tohtml($i) ?>" class="u-hide-desktop"><?= tohtml( _("Select")) ?></label>
  138. </div>
  139. </div>
  140. <div class="units-table-cell units-table-heading-cell u-text-bold">
  141. <span class="u-hide-desktop"><?= tohtml( _("Service")) ?>:</span>
  142. <i class="fas <?= tohtml($state_icon) ?> u-mr5"></i>
  143. <a href="/edit/server/<? echo $edit_url ?>/" title="<?= tohtml( _("Edit")) ?>: <?= tohtml($key) ?>">
  144. <?= tohtml($key) ?>
  145. </a>
  146. </div>
  147. <div class="units-table-cell">
  148. <ul class="units-table-row-actions">
  149. <li class="units-table-row-action shortcut-enter" data-key-action="href">
  150. <a
  151. class="units-table-row-action-link"
  152. href="/edit/server/<? echo $edit_url ?>/"
  153. title="<?= tohtml( _("Edit")) ?>"
  154. >
  155. <i class="fas fa-pencil icon-orange"></i>
  156. <span class="u-hide-desktop"><?= tohtml( _("Edit")) ?></span>
  157. </a>
  158. </li>
  159. <li class="units-table-row-action shortcut-s" data-key-action="js">
  160. <a
  161. class="units-table-row-action-link data-controls js-confirm-action"
  162. href="/restart/service/?<?= tohtml(http_build_query(["srv" => $key, "token" => $_SESSION["token"]])) ?>"
  163. title="<?= tohtml( _("Restart")) ?>"
  164. data-confirm-title="<?= tohtml( _("Restart")) ?>"
  165. data-confirm-message="<?= tohtml(sprintf(_("Are you sure you want to restart the %s service?"), $key)) ?>"
  166. >
  167. <i class="fas fa-arrow-rotate-left icon-highlight"></i>
  168. <span class="u-hide-desktop"><?= tohtml( _("Restart")) ?></span>
  169. </a>
  170. </li>
  171. <li class="units-table-row-action shortcut-delete" data-key-action="js">
  172. <a
  173. class="units-table-row-action-link data-controls js-confirm-action"
  174. href="/<?= tohtml($action) ?>/service/?<?= tohtml(http_build_query(["srv" => $key, "token" => $_SESSION["token"]])) ?>"
  175. title="<?= tohtml($action_text) ?>"
  176. data-confirm-title="<?= tohtml($action_text) ?>"
  177. data-confirm-message="<?php if ($action == 'stop') { echo sprintf(_('Are you sure you want to stop the %s service?'), $key); } else { echo sprintf(_('Are you sure you want to start the %s service?'), $key); }?>"
  178. >
  179. <i class="fas <?= tohtml($spnd_icon) ?> <?= tohtml($spnd_icon_class) ?>"></i>
  180. <span class="u-hide-desktop"><?= tohtml($action_text) ?></span>
  181. </a>
  182. </li>
  183. </ul>
  184. </div>
  185. <div class="units-table-cell">
  186. <span class="u-hide-desktop u-text-bold"><?= tohtml( _("Description")) ?>:</span>
  187. <?= tohtml( _($data[$key]["SYSTEM"])) ?>
  188. </div>
  189. <div class="units-table-cell u-text-bold u-text-center-desktop">
  190. <span class="u-hide-desktop"><?= tohtml( _("Uptime")) ?>:</span>
  191. <?= tohtml(humanize_time($data[$key]["RTIME"])) ?>
  192. </div>
  193. <div class="units-table-cell u-text-bold u-text-center-desktop">
  194. <span class="u-hide-desktop"><?= tohtml( _("CPU")) ?>:</span>
  195. <?= tohtml($cpu) ?>
  196. </div>
  197. <div class="units-table-cell u-text-bold u-text-center-desktop">
  198. <span class="u-hide-desktop"><?= tohtml( _("Memory")) ?>:</span>
  199. <?= tohtml($data[$key]["MEM"]) ?> <?= tohtml( _("MB")) ?>
  200. </div>
  201. </div>
  202. <?php } ?>
  203. </div>
  204. </div>