Commit 34eeba3f authored by Vladislav Gumerov's avatar Vladislav Gumerov

added data table

parent 25923447
#.idea folder
.idea/
\ No newline at end of file
<?php
$cpu = shell_exec('ps aux | awk \'{s += $3} END {print s "%"}\'');
$total_mem = shell_exec("cat /proc/meminfo | grep MemTotal | awk '{ print $2 }' ");
$free_mem = shell_exec("cat /proc/meminfo | grep MemFree | awk '{ print $2 }' ");
$average1 = shell_exec("uptime | awk '{ print $10 }' ");
$average2 = shell_exec("uptime | awk '{ print $11 }' ");
$average3 = shell_exec("uptime | awk '{ print $12 }' ");
$arr = array('CPI' => trim($cpu),
'TotalMemory' => trim($total_mem),
'FreeMemory' => trim($free_mem),
"5minute" => substr(trim($average1), 0, -1),
"10minute" => substr(trim($average2), 0, -1),
"15minute" => substr(trim($average3), 0, -1));
exit (json_encode($arr));
?>
\ No newline at end of file
table {
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 14px;
border-collapse: collapse;
text-align: center;
}
th, td:first-child {
background: #AFCDE7;
color: white;
padding: 10px 20px;
}
th, td {
border-style: solid;
border-width: 0 1px 1px 0;
border-color: white;
}
td {
background: #D8E6F3;
}
th:first-child, td:first-child {
text-align: left;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>itersoft</title>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<table class="system-load-table" width="100%">
<tr class="first_row">
<th>CPU</th>
<th>Total memory</th>
<th>Free memory</th>
<th>5 minute</th>
<th>10 minute</th>
<th>15 minute</th>
</tr>
<tr class="second-row">
<th>0</th>
<th>0</th>
<th>0</th>
<th>0</th>
<th>0</th>
<th>0</th>
</tr>
</table>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="js/index.js"></script>
</body>
</html>
\ No newline at end of file
let secondRow = $('.second-row').children();
interval = setInterval(function() {
$.get('core/etersoft.php', function (data) {
data = JSON.parse(data);
let i = 0;
console.log(data);
$.each(data, function (index, elem) {
secondRow[i].innerHTML = elem;
i++;
});
})
}, 2000);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment