Merge branch 'remastering' of https://gitea.steelants.cz/SH/PHP_SMART_HOME_V3 into remastering

This commit is contained in:
haitem 2020-10-31 15:10:38 +01:00
commit 38cc436f4d
2 changed files with 33 additions and 25 deletions

View File

@ -16,9 +16,16 @@ class Server extends Template
return $meminfo; return $meminfo;
} }
function __construct() private function getProcessorUsage(){
{ $loads=sys_getloadavg();
$userManager = new UserManager(); $core_nums=trim(shell_exec("grep -P '^physical id' /proc/cpuinfo|wc -l"));
$load = round($loads[0]/($core_nums + 1)*100, 2);
return $load;
}
function __construct()
{
$userManager = new UserManager();
$langMng = new LanguageManager('en'); $langMng = new LanguageManager('en');
if (!$userManager->isLogin()){ if (!$userManager->isLogin()){
@ -37,7 +44,7 @@ class Server extends Template
$template->prepare('ip', $_SERVER['SERVER_ADDR']); $template->prepare('ip', $_SERVER['SERVER_ADDR']);
$template->prepare('name', $_SERVER['SERVER_NAME']); $template->prepare('name', $_SERVER['SERVER_NAME']);
$template->prepare('CPU', sys_getloadavg()[0]); $template->prepare('CPU', $this->getProcessorUsage());
$template->prepare('ramFree', $this->getSystemMemInfo()["MemFree"]); $template->prepare('ramFree', $this->getSystemMemInfo()["MemFree"]);
$template->prepare('ramTotal', $this->getSystemMemInfo()["MemTotal"]); $template->prepare('ramTotal', $this->getSystemMemInfo()["MemTotal"]);
$template->prepare('diskFree', disk_free_space("/")); $template->prepare('diskFree', disk_free_space("/"));

View File

@ -13,41 +13,42 @@
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<?php <?php
$partial = new Partial('menu'); $partial = new Partial('menu');
$partial->prepare('item', 'log'); $partial->prepare('item', 'log');
$partial->prepare('langMng',$LANGMNG); $partial->prepare('langMng',$LANGMNG);
$partial->prepare('debugMod',$DEBUGMOD); $partial->prepare('debugMod',$DEBUGMOD);
$partial->render(); $partial->render();
?> ?>
</div> </div>
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4"> <div class="col-12 col-sm-9 mx-auto mt-4">
<h1><?php echo $LANGMNG->get('t_ServerStats'); ?></h1> <h1><?php echo $LANGMNG->get('t_ServerStats'); ?></h1>
<hr> <hr>
<label>UPTIME: <?php echo $UPTIME;?></label></br> <label>UPTIME: <?php echo $UPTIME;?></label></br>
<label>SERVER TIME: <?php echo $SERVERTIME;?></label></br> <label>SERVER TIME: <?php echo $SERVERTIME;?></label></br>
<label>SERVER NAME: <?php echo $NAME;?></label></br> <label>SERVER NAME: <?php echo $NAME;?></label></br>
<label>SERVER ADDRESS: <?php echo $IP;?></label></br> <label>SERVER ADDRESS: <?php echo $IP;?></label></br>
<hr> <hr>
<label>CPU: <?php echo $CPU;?></label></br> <label>CPU: <?php echo $CPU;?></label></br>
<label>CPU Usage: </label><progress value="<?php echo $CPU;?>" max="1"> <?php echo $RAMFREE;?> </progress></br> <label>CPU Usage: </label><progress value="<?php echo $CPU;?>" max="100"> <?php echo $RAMFREE;?> </progress></br>
<hr> <hr>
<label>RAM TOTAL: <?php echo $RAMTOTAL;?></label></br> <label>RAM TOTAL: <?php echo $RAMTOTAL;?></label></br>
<label>RAM FREE: <?php echo $RAMFREE;?></label></br> <label>RAM FREE: <?php echo $RAMFREE;?></label></br>
<label>RAM Usage: </label><progress value="<?php echo explode(" ", $RAMTOTAL)[0] - explode(" ", $RAMFREE)[0];?>" max="<?php echo explode(" ", $RAMTOTAL)[0];?>"> <?php echo $RAMFREE;?> </progress></br> <label>RAM Usage: </label><progress value="<?php echo explode(" ", $RAMTOTAL)[0] - explode(" ", $RAMFREE)[0];?>" max="<?php echo explode(" ", $RAMTOTAL)[0];?>"> <?php echo $RAMFREE;?> </progress></br>
<hr> <hr>
<label>DISK TOTAL: <?php echo $DISKTOTAL;?> bytes</label></br> <label>DISK TOTAL: <?php echo $DISKTOTAL;?> bytes</label></br>
<label>DISK FREE: <?php echo $DISKFREE;?> bytes</label></br> <label>DISK FREE: <?php echo $DISKFREE;?> bytes</label></br>
<label>DISK Usage: </label><progress value="<?php echo explode(" ", $DISKTOTAL)[0] - explode(" ", $DISKFREE)[0];?>" max="<?php echo explode(" ", $DISKTOTAL)[0];?>"> <?php echo $DISKFREE;?> </progress></br> <label>DISK Usage: </label><progress value="<?php echo explode(" ", $DISKTOTAL)[0] - explode(" ", $DISKFREE)[0];?>" max="<?php echo explode(" ", $DISKTOTAL)[0];?>"> <?php echo $DISKFREE;?> </progress></br>
<hr> <hr>
</div> </div>
</div> </div>
<?php <?php
$partial = new Partial('footer'); $partial = new Partial('footer');
$partial->prepare('baseDir', BASEDIR); $partial->prepare('baseDir', BASEDIR);
$partial->render(); $partial->render();
//TODO js do main.js //TODO js do main.js
?> ?>
</body> </body>
</html> </html>