From c0e01e261a566a1d62168a0887a61e559338df14 Mon Sep 17 00:00:00 2001 From: dg9vh Date: Fri, 8 Jul 2016 18:17:27 +0000 Subject: [PATCH] only show temp and freq of cpu when available --- include/sysinfo.php | 46 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/include/sysinfo.php b/include/sysinfo.php index 1532b9e..c09724a 100644 --- a/include/sysinfo.php +++ b/include/sysinfo.php @@ -1,8 +1,16 @@ TEMPERATUREHIGHLEVEL) { + $cputemp = NULL; + $cpufreq = NULL; + if (file_exists ("/sys/class/thermal/thermal_zone0/temp")) { + exec("cat /sys/class/thermal/thermal_zone0/temp", $cputemp); + $cputemp = $cputemp[0] / 1000; + } + 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) { ?>