1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Merge pull request #479 from Weylin-fr/adding-cpu-temperature

Adding cpu temperature
This commit is contained in:
Bill Zimmerman 2020-01-22 11:04:43 +01:00 committed by GitHub
commit 8ff2167a75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -45,5 +45,10 @@ class System {
public function systemLoadPercentage() {
return intval(($this->loadAvg1Min() * 100) / $this->processorCount());
}
public function systemTemperature() {
$cpuTemp = file_get_contents("/sys/class/thermal/thermal_zone0/temp");
return number_format($cpuTemp/1000, 1);
}
}

View File

@ -25,6 +25,16 @@ if ($cpuload > 90) {
$cpuload_status = "success";
}
// cpu temp
$cputemp = $system->systemTemperature();
if ($cputemp > 70) {
$cputemp_status = "danger";
} elseif ($cputemp > 50) {
$cputemp_status = "warning";
} else {
$cputemp_status = "success";
}
?>
<div class="row">
<div class="col-lg-12">
@ -63,12 +73,19 @@ if ($cpuload > 90) {
</div>
</div>
<div class="mb-1"><?php echo _("CPU Load"); ?></div>
<div class="progress mb-4" style="height: 20px;">
<div class="progress mb-2" style="height: 20px;">
<div class="progress-bar bg-<?php echo htmlspecialchars($cpuload_status, ENT_QUOTES); ?>"
role="progressbar" aria-valuenow="<?php echo htmlspecialchars($cpuload, ENT_QUOTES); ?>" aria-valuemin="0" aria-valuemax="100"
style="width: <?php echo htmlspecialchars($cpuload, ENT_QUOTES); ?>%"><?php echo htmlspecialchars($cpuload, ENT_QUOTES); ?>%
</div>
</div>
<div class="mb-1"><?php echo _("CPU Temp"); ?></div>
<div class="progress mb-4" style="height: 20px;">
<div class="progress-bar bg-<?php echo htmlspecialchars($cputemp_status, ENT_QUOTES); ?>"
role="progressbar" aria-valuenow="<?php echo htmlspecialchars($cputemp, ENT_QUOTES); ?>" aria-valuemin="0" aria-valuemax="100"
style="width: <?php echo htmlspecialchars(($cputemp*1.2), ENT_QUOTES); ?>%"><?php echo htmlspecialchars($cputemp, ENT_QUOTES); ?>°C
</div>
</div>
<form action="?page=system_info" method="POST">
<?php echo CSRFTokenFieldTag() ?>