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