only show temp and freq of cpu when available

This commit is contained in:
dg9vh 2016-07-08 18:17:27 +00:00
parent 2b4ae69865
commit c0e01e261a

View file

@ -1,8 +1,16 @@
<?php
$cputemp = NULL;
$cpufreq = NULL;
if (file_exists ("/sys/class/thermal/thermal_zone0/temp")) {
exec("cat /sys/class/thermal/thermal_zone0/temp", $cputemp);
exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $cpufreq);
$cputemp = $cputemp[0] / 1000;
if (defined("TEMPERATUREALERT") && $cputemp > TEMPERATUREHIGHLEVEL) {
}
if (file_exists ("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")) {
exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $cpufreq);
$cpufreq = $cpufreq[0] / 1000;
}
if (defined("TEMPERATUREALERT") && $cputemp > TEMPERATUREHIGHLEVEL && $cputemp !== NULL) {
?>
<script>
function deleteLayer(id) {
@ -62,8 +70,6 @@
<?php
}
$cpufreq = $cpufreq[0] / 1000;
$output = shell_exec('cat /proc/loadavg');
$sysload = substr($output,0,strpos($output," "))*100;
@ -95,19 +101,43 @@
<div class="panel-heading">System Info</div>
<!-- Tabelle -->
<div class="table-responsive">
<table class="table">
<table id="sysinfo" class="table table-condensed">
<tbody>
<tr>
<?php
if ($cputemp !== NULL) {
?>
<th>CPU-Temperature</th>
<?php
}
?>
<?php
if ($cpufreq !== NULL) {
?>
<th>CPU-Frequency</th>
<?php
}
?>
<th>System-Load</th>
<th>CPU-Usage</th>
<th>Uptime</th>
<th>Idle</th>
</tr>
<tr class="gatewayinfo">
<?php
if ($cputemp !== NULL) {
?>
<td><?php echo $cputemp; ?> &deg;C</td>
<?php
}
?>
<?php
if ($cpufreq !== NULL) {
?>
<td><?php echo $cpufreq; ?> MHz</td>
<?php
}
?>
<td><?php echo $sysload; ?> %</td>
<td>
<?php