友情提示点击顶部放大镜 可以使用站内搜索 记住我们的地址 www.hainabaike.com
将下面的代码复制下来保存为php页面,访问这个页面就能查看实时的树莓派状态信息了。原理是打印shell_exec的结果。
<?php
/**
* state
*
* @package custom
*/
?>
<article class="content">
<section class="post">
<div id='server_state'>
<h5>uname -a</h5>
<pre><?php echo shell_exec("uname -a"); ?></pre><br/>
<h5>Uptime</h5>
<pre><?php echo ltrim(shell_exec("uptime"), " "); ?></pre><br/>
<h5>cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq </h5>
<pre>
<?php
$t = shell_exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq");
echo sprintf("%s/1000=%sKHz", str_replace("
", "", $t), $t/1000);
?>
</pre><br/>
<h5>cat /sys/class/thermal/thermal_zone0/temp </h5>
<pre>
<?php
$t = shell_exec("cat /sys/class/thermal/thermal_zone0/temp");
echo sprintf("%s/1000=%sC°", str_replace("
", "", $t), $t/1000);
?>
</pre><br/>
<h5>free -h</h5>
<pre><?php echo shell_exec("free -h"); ?></pre><br/>
<h5>cat /proc/cpuinfo</h5>
<pre><?php echo shell_exec("cat /proc/cpuinfo"); ?></pre>
</div>
via
标签: 树莓派raspberrypilevel3webphp
文章来源:
树莓派实验室
版权声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除。



评论列表