summaryrefslogtreecommitdiffstats
path: root/pts-core/functions/pts-functions_system_parsing.php
diff options
context:
space:
mode:
authorMichael Larabel <michael@phx-laptop.(none)>2008-11-19 18:00:55 -0500
committerMichael Larabel <michael@phx-laptop.(none)>2008-11-19 18:00:55 -0500
commitbbe8de3303639275ace58eb615678100629e1b70 (patch)
tree300297343395d664e52bd68134528b50dce650d4 /pts-core/functions/pts-functions_system_parsing.php
parent8d02551b35efa56a31c64a13ff0552500bf72bbd (diff)
downloadphoronix-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.php16
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;