diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-10-21 13:52:28 -0400 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-10-21 13:52:28 -0400 |
commit | 139577a6d076e528d4ee77674a2ab20570d1dc1f (patch) | |
tree | 40067b1fb9567c89b6137570bd3fa7a911f890a8 /pts-core/functions/pts-functions_system_parsing.php | |
parent | b592434693bd1e461d51daffe59f9fb05ed50d8d (diff) | |
download | phoronix-test-suite-upstream-139577a6d076e528d4ee77674a2ab20570d1dc1f.tar.gz phoronix-test-suite-upstream-139577a6d076e528d4ee77674a2ab20570d1dc1f.tar.xz phoronix-test-suite-upstream-139577a6d076e528d4ee77674a2ab20570d1dc1f.zip |
pts-core: Add support for reading DMI information from dmidecode where
available through the read_dmidecode() function
Diffstat (limited to 'pts-core/functions/pts-functions_system_parsing.php')
-rw-r--r-- | pts-core/functions/pts-functions_system_parsing.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php index 6f04158..0d245f1 100644 --- a/pts-core/functions/pts-functions_system_parsing.php +++ b/pts-core/functions/pts-functions_system_parsing.php @@ -646,6 +646,52 @@ function read_osx_system_profiler($data_type, $object) return $value; } +function read_dmidecode($type, $sub_type, $object, $find_once = false) +{ + // Read Linux dmidecode + $value = array(); + + if(is_readable("/dev/mem")) + { + $dmidecode = shell_exec("dmidecode --type " . $type . " 2>&1"); + $sub_type = "\n" . $sub_type . "\n"; + + do + { + $sub_type_start = strpos($dmidecode, $sub_type); + + if($sub_type_start !== false) + { + $dmidecode = substr($dmidecode, ($sub_type_start + strlen($sub_type))); + $dmidecode_section = substr($dmidecode, 0, strpos($dmidecode, "\n\n")); + $dmidecode = substr($dmidecode, strlen($dmidecode_section)); + $dmidecode_elements = explode("\n", $dmidecode_section); + + for($i = 0; $i < count($dmidecode_elements) && ($find_once == false || $value == false); $i++) + { + $dmidecode_r = explode(":", $dmidecode_elements[$i]); + + if(trim($dmidecode_r[0]) == $object && isset($dmidecode_r[1])) + { + array_push($value, trim($dmidecode_r[1])); + } + } + } + } + while($sub_type_start !== false && $find_once == false); + } + + if(count($value) == 0) + { + $value = false; + } + else if($fine_once != false && count($value) == 1) + { + $value = $value[0]; + } + + return $value; +} function read_sun_ddu_dmi_info($object) { // Read Sun's Device Driver Utility for OpenSolaris |