diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-11-19 18:00:55 -0500 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-11-19 18:00:55 -0500 |
commit | bbe8de3303639275ace58eb615678100629e1b70 (patch) | |
tree | 300297343395d664e52bd68134528b50dce650d4 /pts-core/functions/pts-functions_system_parsing.php | |
parent | 8d02551b35efa56a31c64a13ff0552500bf72bbd (diff) | |
download | phoronix-test-suite-upstream-bbe8de3303639275ace58eb615678100629e1b70.tar.gz phoronix-test-suite-upstream-bbe8de3303639275ace58eb615678100629e1b70.tar.xz phoronix-test-suite-upstream-bbe8de3303639275ace58eb615678100629e1b70.zip |
pts-core: Add fallback option support for read_sysctl()
Diffstat (limited to 'pts-core/functions/pts-functions_system_parsing.php')
-rw-r--r-- | pts-core/functions/pts-functions_system_parsing.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php index c99560e..edaad5a 100644 --- a/pts-core/functions/pts-functions_system_parsing.php +++ b/pts-core/functions/pts-functions_system_parsing.php @@ -216,15 +216,21 @@ function read_lsb($desc) function read_sysctl($desc) { // Read sysctl, used by *BSDs - $info = shell_exec("sysctl $desc 2>&1"); + $info = "Unknown"; - if(($point = strpos($info, ":")) > 0 || ($point = strpos($info, "=")) > 0) + if(!is_array($desc)) { - $info = trim(substr($info, $point + 1)); + $desc = array($desc); } - else + + for($i = 0; $i < count($desc) && $info == "Unknown"; $i++) { - $info = "Unknown"; + $output = shell_exec("sysctl " . $desc[$i] . " 2>&1"); + + if((($point = strpos($output, ":")) > 0 || ($point = strpos($output, "=")) > 0) && strpos($output, "unknown oid") === false) + { + $info = trim(substr($output, $point + 1)); + } } return $info; |