diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-08-17 13:16:20 -0400 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-08-17 13:16:20 -0400 |
commit | 91738453eaaa3f2d7a28ca6d5a4bc4a3c4a80d8c (patch) | |
tree | a5e44a8023dcf04829f789ce3f8185467caaef9b /pts-core/functions/pts-functions_system_parsing.php | |
parent | c7387ec9b2b49f644afcfac46ce0d397802d0521 (diff) | |
download | phoronix-test-suite-upstream-91738453eaaa3f2d7a28ca6d5a4bc4a3c4a80d8c.tar.gz phoronix-test-suite-upstream-91738453eaaa3f2d7a28ca6d5a4bc4a3c4a80d8c.tar.xz phoronix-test-suite-upstream-91738453eaaa3f2d7a28ca6d5a4bc4a3c4a80d8c.zip |
pts-core: For LM_Sensors parsing with read_sensors() support an array as
an argument for multiple possible values
Diffstat (limited to 'pts-core/functions/pts-functions_system_parsing.php')
-rw-r--r-- | pts-core/functions/pts-functions_system_parsing.php | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php index c6ba28f..88ac452 100644 --- a/pts-core/functions/pts-functions_system_parsing.php +++ b/pts-core/functions/pts-functions_system_parsing.php @@ -73,24 +73,31 @@ function read_system_hal($name) { return read_hal($name, "/org/freedesktop/Hal/devices/computer"); } -function read_sensors($attribute) +function read_sensors($attributes) { $value = ""; $sensors = shell_exec("sensors 2>&1"); $sensors_lines = explode("\n", $sensors); - for($i = 0; $i < count($sensors_lines) && $value == ""; $i++) - { - $line = explode(": ", $sensors_lines[$i]); - $this_attribute = trim($line[0]); + if(!is_array($attributes)) + $attributes = array($attributes); - if($this_attribute == $attribute) + for($j = 0; $j < count($attributes) && empty($value); $j++) + { + $attribute = $attributes[$j]; + for($i = 0; $i < count($sensors_lines) && empty($value); $i++) { - $this_remainder = trim(str_replace(array('+', '°'), ' ', $line[1])); - $this_value = substr($this_remainder, 0, strpos($this_remainder, ' ')); + $line = explode(": ", $sensors_lines[$i]); + $this_attribute = trim($line[0]); - if(is_numeric($this_value)) - $value = $this_value; + if($this_attribute == $attribute) + { + $this_remainder = trim(str_replace(array('+', '°'), ' ', $line[1])); + $this_value = substr($this_remainder, 0, strpos($this_remainder, ' ')); + + if(is_numeric($this_value)) + $value = $this_value; + } } } |