pull/25/head
spoony 2020-05-05 00:08:40 +08:00
parent 77d5f82296
commit e741fc6341
7 changed files with 29 additions and 26 deletions

View File

@ -1,8 +1,8 @@
# Pi Dashboard
A WebUI dashboard for IoT devices likes raspberry pi.
Project details: (http://maker.quwj.com/project/10)
Project details: (http://make.quwj.com/project/10)
Copyright 2017 NXEZ.com.
Copyright 2017-2020 NXEZ.com.
Licensed under the GPL v3.0 license.

View File

@ -398,7 +398,7 @@ $(document).ready(function() {
point.update(Math.round((1.0 - (idle_diff / used_total)) * 100 * Math.pow(10,1))/Math.pow(10,1));
}
$("#cpu-freq").text(window.dashboard.cpu.freq / 1000);
$("#cpu-stat-idl").text(Math.round(((parseInt(window.dashboard.cpu.stat.idle) - parseInt(window.dashboard_old.cpu.stat.idle)) / used_total) * 100 * Math.pow(10,1))/Math.pow(10,1));
$("#cpu-stat-use").text(Math.round(((parseInt(window.dashboard.cpu.stat.user) - parseInt(window.dashboard_old.cpu.stat.user)) / used_total) * 100 * Math.pow(10,1))/Math.pow(10,1));
$("#cpu-stat-sys").text(Math.round(((parseInt(window.dashboard.cpu.stat.sys) - parseInt(window.dashboard_old.cpu.stat.sys)) / used_total) * 100 * Math.pow(10,1))/Math.pow(10,1));

File diff suppressed because one or more lines are too long

BIN
assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -18,7 +18,7 @@ if (isset($_GET['ajax']) && $_GET['ajax'] == "true"){
exit;
}
$D['version'] = '1.0.0';
$D['version'] = '1.1.0';
$D['model'] = get_device_model();
$D['user'] = @get_current_user();
$D['hostname'] = gethostname();
@ -27,18 +27,11 @@ $D['yourip'] = $_SERVER['REMOTE_ADDR'];
$D['uname'] = @php_uname();
$D['os'] = explode(" ", php_uname());
if (($str = @file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")) !== false){
$D['cpu']['freq'] = $str[0];
}
else{
$D['cpu']['freq'] = 0;
}
if (($str = @file("/proc/cpuinfo")) !== false){
$str = implode("", $str);
@preg_match_all("/model\s+name\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $model);
@preg_match_all("/BogoMIPS\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $bogomips);
@preg_match_all("/Model\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $pimodel);
if (false !== is_array($model[1])){
$D['cpu']['count'] = sizeof($model[1]);
@ -50,10 +43,15 @@ if (($str = @file("/proc/cpuinfo")) !== false){
$D['cpu']['model'] = $model[1][0].$bogomips[1][0].' ×'.$D['cpu']['count'];
}
}
if (false !== is_array($pimodel[1])){
$D['model']['pimodel'] = $pimodel[1][0];
}
}
else{
$D['cpu']['count'] = 1;
$D['cpu']['model'] = '';
$D['model']['pimodel'] = '';
}
function get_device_model(){
@ -73,6 +71,13 @@ function get_info(){
$D['uptime'] = 0;
}
if (($str = @file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")) !== false){
$D['cpu']['freq'] = $str[0];
}
else{
$D['cpu']['freq'] = 0;
}
// CPU Core
if (($str = @file("/proc/stat")) !== false){
$str = str_replace(" ", " ", $str);
@ -175,4 +180,4 @@ function get_info(){
$D['net']['count'] = 0;
}
}
?>
?>

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -7,12 +7,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'device.php');
<title>Pi Dashboard</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/solid-gauge.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script-->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link href="assets/bootstrap.min.css" rel="stylesheet">
<script src="assets/jquery-3.1.1.min.js"></script>
<script src="assets/highcharts.js"></script>
@ -40,16 +35,17 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'device.php');
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Pi Dashboard</a>
<a class="navbar-brand" href="#"><img style="height: 100%; display: inline; margin-right: 10px;" src="assets/logo.png">Pi Dashboard</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a target="_blank" href="http://shumeipai.nxez.com">树莓派实验室</a></li>
<li><a target="_blank" href="https://shumeipai.nxez.com">树莓派实验室</a></li>
<li><a target="_blank" href="https://talk.quwj.com">趣小组</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">About <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a target="_blank" href="http://maker.quwj.com/project/10">Pi Dashboard</a></li>
<li><a target="_blank" href="https://make.quwj.com/project/10">Pi Dashboard</a></li>
<li><a target="_blank" href="https://github.com/spoonysonny/pi-dashboard">GitHub Source</a></li>
</ul>
</li>
@ -63,6 +59,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'device.php');
<div class="col-md-3">
<div style="text-align: center; padding: 20px 0;"><img src="assets/devices/<?php echo($D['model']['id']) ?>.png" /></div>
<div style="background-color: #E0E0E0; padding: 5px; border-radius: 3px;">
<div class="text-center" style="margin:10px; padding: 10px 0 10px 0; border-radius: 3px;"><div id="pimodel" style="font-size: 90%; font-weight: bolder; text-shadow: 0 1px 0 #fff;"><?php echo($D['model']['pimodel']); ?></div></div>
<div class="text-center" style="margin:20px; padding: 10px 0 10px 0; background-color:#CEFCA3; border-radius: 3px;"><div class="label">IP</div><div id="hostip" style="font-size: 150%; font-weight: bolder;"><?php echo($D['hostip']); ?></div></div>
<div class="text-center" style="margin:20px; padding: 10px 0 10px 0; background-color:#9DCFFB; border-radius: 3px;"><div class="label">TIME</div><div id="time" style="font-size: 150%; font-weight: bolder;">00:00</div><div id="date">-</div></div>
<div class="text-center" style="margin:20px; padding: 10px 0 10px 0; background-color:#FFFECD; border-radius: 3px;"><div class="label">UPTIME</div><div id="uptime" style="font-size: 120%; font-weight: bolder;">0</div></div>
@ -239,7 +236,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'device.php');
<div class="col-md-12">
<div id="footer">
<hr style="margin: 20px 0 10px 0;" />
<p class="pull-left" style="font-size: 12px;">Powered by <a target="_blank" href="http://maker.quwj.com/project/10"><strong>Pi Dashboard</strong></a> v<?php echo($D['version']) ?>, <a target="_blank" href="http://www.nxez.com">NXEZ.com</a> all rights reserved.
<p class="pull-left" style="font-size: 12px;">Powered by <a target="_blank" href="https://make.quwj.com/project/10"><strong>Pi Dashboard</strong></a> v<?php echo($D['version']) ?>, <a target="_blank" href="https://www.nxez.com">NXEZ.com</a> all rights reserved.
</p>
</div>
</div>
@ -248,4 +245,4 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'device.php');
</div>
<script src="assets/dashboard.min.js"></script>
</body>
</html>
</html>