diff options
author | Renato Botelho <renato@netgate.com> | 2015-10-09 11:10:19 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2015-10-09 11:11:31 -0300 |
commit | 8822be67ce3085c30a1127960d6c8ae1d7eb1876 (patch) | |
tree | 2d8095a1a8869c21e6ebd5cec39c967b159bf7e2 /src | |
parent | 3928c6f1bcf911097366f075994dc9a61716e6e3 (diff) | |
download | pfsense-8822be67ce3085c30a1127960d6c8ae1d7eb1876.zip pfsense-8822be67ce3085c30a1127960d6c8ae1d7eb1876.tar.gz |
Ignore possible erroneously negative temperatures
It's based on 2 pull requests (#1800 and #1801) by nagyrobi
Diffstat (limited to 'src')
-rw-r--r-- | src/usr/local/www/includes/functions.inc.php | 10 | ||||
-rw-r--r-- | src/usr/local/www/widgets/include/thermal_sensors.inc | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/usr/local/www/includes/functions.inc.php b/src/usr/local/www/includes/functions.inc.php index 2c48543..3bb3edd 100644 --- a/src/usr/local/www/includes/functions.inc.php +++ b/src/usr/local/www/includes/functions.inc.php @@ -233,8 +233,14 @@ function get_temp() { $temp_out = get_single_sysctl("hw.acpi.thermal.tz0.temperature"); } - // Remove 'C' from the end - return rtrim($temp_out, 'C'); + // Remove 'C' from the end and spaces + $temp_out = trim(rtrim($temp_out, 'C')); + + if ($temp_out[0] == '-') { + return ''; + } + + return $temp_out; } /* Get mounted filesystems and usage. Do not display entries for virtual filesystems (e.g. devfs, nullfs, unionfs) */ diff --git a/src/usr/local/www/widgets/include/thermal_sensors.inc b/src/usr/local/www/widgets/include/thermal_sensors.inc index a6e727a..e6ddb58 100644 --- a/src/usr/local/www/widgets/include/thermal_sensors.inc +++ b/src/usr/local/www/widgets/include/thermal_sensors.inc @@ -20,8 +20,10 @@ $thermal_sensors_widget_title = "Thermal Sensors"; function getThermalSensorsData() { $_gb = exec("/sbin/sysctl -a | grep temperature", $dfout); - $thermalSensorsData = join("|", $dfout); - return $thermalSensorsData; + $dfout_filtered = array_filter($dfout, function($v) { + return strpos($negsign, ' -') === false; + }); + return join("|", $dfout_filtered); } ?> |