Server Info basic layout

This commit is contained in:
Václav Španinger 2020-07-23 17:58:46 +02:00
parent 880b01882a
commit 3d68df2658
6 changed files with 110 additions and 45 deletions

View File

@ -9,6 +9,7 @@ $router->setDefault(function(){
//Pages
$router->any('/', 'Log');
$router->any('/log', 'Log');
$router->any('/server', 'Server');
$router->any('/login', 'Login');
$router->any('/logout', 'Logout');
$router->any('/automation', 'Automation');

View File

@ -3,19 +3,6 @@
class Log extends Template
{
//TODO: to server manager
function getSystemMemInfo()
{
$data = explode("\n", file_get_contents("/proc/meminfo"));
$meminfo = array();
foreach ($data as $line) {
$data = explode(":", $line);
if (count($data)!=2) continue;
$meminfo[$data[0]] = trim($data[1]);
}
return $meminfo;
}
function __construct()
{
$userManager = new UserManager();
@ -45,22 +32,7 @@ class Log extends Template
$template->prepare('title', 'Logy');
$template->prepare('logsFiles', $result);
$template->prepare('langMng', $langMng);
$template->prepare('CPU', sys_getloadavg()[0]);
$template->prepare('UPTIME', shell_exec('uptime -p'));
$template->prepare('ramFree', $this->getSystemMemInfo()["MemFree"]);
$template->prepare('ramTotal', $this->getSystemMemInfo()["MemTotal"]);
$template->prepare('diskFree', disk_free_space("/"));
$template->prepare('diskTotal', disk_total_space("/"));
$template->prepare('serverTime', date('m. d. Y H:i:s - e'));
$template->render();
}
}

51
app/views/Server.php Normal file
View File

@ -0,0 +1,51 @@
<?php
class Server extends Template
{
//TODO: to server manager
private function getSystemMemInfo()
{
$data = explode("\n", file_get_contents("/proc/meminfo"));
$meminfo = array();
foreach ($data as $line) {
$data = explode(":", $line);
if (count($data)!=2) continue;
$meminfo[$data[0]] = trim($data[1]);
}
return $meminfo;
}
function __construct()
{
$userManager = new UserManager();
$langMng = new LanguageManager('en');
if (!$userManager->isLogin()){
header('Location: ' . BASEURL . 'login');
}
$template = new Template('server');
$template->prepare('title', 'Server');
$template->prepare('baseDir', BASEDIR);
$template->prepare('debugMod', DEBUGMOD);
$template->prepare('langMng', $langMng);
$template->prepare('UPTIME', shell_exec('uptime -p'));
$template->prepare('serverTime', date('m. d. Y H:i:s - e'));
$template->prepare('ip', $_SERVER['SERVER_ADDR']);
$template->prepare('name', $_SERVER['SERVER_NAME']);
echo $_SERVER['SERVER_NAME'];
$template->prepare('CPU', sys_getloadavg()[0]);
$template->prepare('ramFree', $this->getSystemMemInfo()["MemFree"]);
$template->prepare('ramTotal', $this->getSystemMemInfo()["MemTotal"]);
$template->prepare('diskFree', disk_free_space("/"));
$template->prepare('diskTotal', disk_total_space("/"));
$template->render();
}
}

View File

@ -22,23 +22,6 @@
</div>
<div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4">
<h1><?php echo $LANGMNG->get('t_ServerStats'); ?></h1>
<hr>
<label>UPTIME: <?php echo $UPTIME;?></label></br>
<label>SERVER TIME: <?php echo $SERVERTIME;?></label></br>
<hr>
<label>CPU: <?php echo $CPU;?></label></br>
<label>CPU Usage: </label><progress value="<?php echo $CPU;?>" max="1"> <?php echo $RAMFREE;?> </progress></br>
<hr>
<label>RAM TOTAL: <?php echo $RAMTOTAL;?></label></br>
<label>RAM FREE: <?php echo $RAMFREE;?></label></br>
<label>RAM Usage: </label><progress value="<?php echo explode(" ", $RAMFREE)[0];?>" max="<?php echo explode(" ", $RAMTOTAL)[0];?>"> <?php echo $RAMFREE;?> </progress></br>
<hr>
<label>DISK TOTAL: <?php echo $DISKTOTAL;?> bytes</label></br>
<label>DISK FREE: <?php echo $DISKFREE;?> bytes</label></br>
<label>DISK Usage: </label><progress value="<?php echo explode(" ", $DISKFREE)[0];?>" max="<?php echo explode(" ", $DISKTOTAL)[0];?>"> <?php echo $DISKFREE;?> </progress></br>
<hr>
<h1><?php echo $LANGMNG->get('t_Logs'); ?></h1>
<label><?php echo $LANGMNG->get('l_logMaxLiveTime') . " " . $LOGTOLIVETIME . " days";?></label></br>

View File

@ -16,6 +16,11 @@
'lngKey' => 'log',
'path' => 'log',
],
'fa-server' =>[
'slug' => 'server',
'lngKey' => 'server',
'path' => 'server',
],
];
foreach ( $menuItems as $key => $value) {
if ($DEBUGMOD == 0 && $value['path'] == 'log') {

View File

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