本文整理汇总了PHP中PMA_getSysInfoOs函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getSysInfoOs函数的具体用法?PHP PMA_getSysInfoOs怎么用?PHP PMA_getSysInfoOs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_getSysInfoOs函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_getSysInfo
/**
* @return array
*/
function PMA_getSysInfo()
{
$php_os = PMA_getSysInfoOs();
$supported = array('Linux', 'WINNT', 'SunOS');
$sysinfo = array();
if (in_array($php_os, $supported)) {
return eval("return new PMA_sysinfo" . $php_os . "();");
}
return new PMA_Sysinfo_Default();
}
示例2: PMA_getSysInfo
/**
* Gets sysinfo class mathing current OS
*
* @return PMA_SysInfo|mixed sysinfo class
*/
function PMA_getSysInfo()
{
$php_os = PMA_getSysInfoOs();
$supported = array('Linux', 'WINNT', 'SunOS');
if (in_array($php_os, $supported)) {
$class_name = 'PMA_SysInfo' . $php_os;
$ret = new $class_name();
if ($ret->supported()) {
return $ret;
}
}
return new PMA_SysInfo();
}
示例3: PMA_getSysInfo
/**
* Gets sysinfo class mathing current OS
*
* @return sysinfo class
*/
function PMA_getSysInfo()
{
$php_os = PMA_getSysInfoOs();
$supported = array('Linux', 'WINNT', 'SunOS');
$sysinfo = array();
if (in_array($php_os, $supported)) {
$ret = eval("return new PMA_SysInfo" . $php_os . "();");
if ($ret->supported()) {
return $ret;
}
}
return new PMA_SysInfo();
}
示例4: PMA_getSysInfo
/**
* Gets sysinfo class mathing current OS
*
* @return \PMA\libraries\SysInfo|mixed sysinfo class
*/
function PMA_getSysInfo()
{
$php_os = PMA_getSysInfoOs();
$supported = array('Linux', 'WINNT', 'SunOS');
if (in_array($php_os, $supported)) {
$class_name = 'PMA\\libraries\\SysInfo' . $php_os;
/** @var \PMA\libraries\SysInfo $ret */
$ret = new $class_name();
if ($ret->supported()) {
return $ret;
}
}
return new \PMA\libraries\SysInfo();
}
示例5: PMA_getJsonForChartingDataSwitch
/**
* Switch called to get JSON for charting data
*
* @param string $type Type
* @param string $pName Name
* @param array $serverVars Server variable values
* @param array $statusVars Status variable values
* @param array $ret Real-time charting data
* @param mixed $sysinfo System info
* @param mixed $cpuload CPU load
* @param mixed $memory Memory
*
* @return array
*/
function PMA_getJsonForChartingDataSwitch($type, $pName, $serverVars, $statusVars, $ret, $sysinfo, $cpuload, $memory)
{
switch ($type) {
/* We only collect the status and server variables here to
* read them all in one query,
* and only afterwards assign them.
* Also do some white list filtering on the names
*/
case 'servervar':
if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
$serverVars[] = $pName;
}
break;
case 'statusvar':
if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
$statusVars[] = $pName;
}
break;
case 'proc':
$result = $GLOBALS['dbi']->query('SHOW PROCESSLIST');
$ret['value'] = $GLOBALS['dbi']->numRows($result);
break;
case 'cpu':
if (!$sysinfo) {
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
}
if (!$cpuload) {
$cpuload = $sysinfo->loadavg();
}
if (PMA_getSysInfoOs() == 'Linux') {
$ret['idle'] = $cpuload['idle'];
$ret['busy'] = $cpuload['busy'];
} else {
$ret['value'] = $cpuload['loadavg'];
}
break;
case 'memory':
if (!$sysinfo) {
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
}
if (!$memory) {
$memory = $sysinfo->memory();
}
$ret['value'] = isset($memory[$pName]) ? $memory[$pName] : 0;
break;
}
return array($serverVars, $statusVars, $ret);
}
示例6: PMA_DBI_query
case 'proc':
$result = PMA_DBI_query('SHOW PROCESSLIST');
$ret[$chart_id][$node_id][$point_id]['value']
= PMA_DBI_num_rows($result);
break;
case 'cpu':
if (!$sysinfo) {
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
}
if (!$cpuload) {
$cpuload = $sysinfo->loadavg();
}
if (PMA_getSysInfoOs() == 'Linux') {
$ret[$chart_id][$node_id][$point_id]['idle']
= $cpuload['idle'];
$ret[$chart_id][$node_id][$point_id]['busy']
= $cpuload['busy'];
} else {
$ret[$chart_id][$node_id][$point_id]['value']
= $cpuload['loadavg'];
}
break;
case 'memory':
if (!$sysinfo) {
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
示例7: testGetSysInfoOs
/**
* Test for OS detection
*
* @param string $os OS name as returned by PHP_OS
* @param string $expected Expected detected OS name
*
* @return void
*
* @dataProvider sysInfoOsProvider
*/
public function testGetSysInfoOs($os, $expected)
{
$this->assertEquals($expected, PMA_getSysInfoOs($os));
}
示例8: PMA_getJsonForChartingData
/**
* Returns JSon for real-time charting data
*
* @return Array
*/
function PMA_getJsonForChartingData()
{
$ret = json_decode($_REQUEST['requiredData'], true);
$statusVars = array();
$serverVars = array();
$sysinfo = $cpuload = $memory = 0;
$pName = '';
/* Accumulate all required variables and data */
// For each chart
foreach ($ret as $chart_id => $chartNodes) {
// For each data series
foreach ($chartNodes as $node_id => $nodeDataPoints) {
// For each data point in the series (usually just 1)
foreach ($nodeDataPoints as $point_id => $dataPoint) {
$pName = $dataPoint['name'];
switch ($dataPoint['type']) {
/* We only collect the status and server variables here to
* read them all in one query,
* and only afterwards assign them.
* Also do some white list filtering on the names
*/
case 'servervar':
if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
$serverVars[] = $pName;
}
break;
case 'statusvar':
if (!preg_match('/[^a-zA-Z_]+/', $pName)) {
$statusVars[] = $pName;
}
break;
case 'proc':
$result = $GLOBALS['dbi']->query('SHOW PROCESSLIST');
$ret[$chart_id][$node_id][$point_id]['value'] = $GLOBALS['dbi']->numRows($result);
break;
case 'cpu':
if (!$sysinfo) {
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
}
if (!$cpuload) {
$cpuload = $sysinfo->loadavg();
}
if (PMA_getSysInfoOs() == 'Linux') {
$ret[$chart_id][$node_id][$point_id]['idle'] = $cpuload['idle'];
$ret[$chart_id][$node_id][$point_id]['busy'] = $cpuload['busy'];
} else {
$ret[$chart_id][$node_id][$point_id]['value'] = $cpuload['loadavg'];
}
break;
case 'memory':
if (!$sysinfo) {
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
}
if (!$memory) {
$memory = $sysinfo->memory();
}
$ret[$chart_id][$node_id][$point_id]['value'] = $memory[$pName];
break;
}
/* switch */
}
/* foreach */
}
/* foreach */
}
/* foreach */
// Retrieve all required status variables
if (count($statusVars)) {
$statusVarValues = $GLOBALS['dbi']->fetchResult("SHOW GLOBAL STATUS WHERE Variable_name='" . implode("' OR Variable_name='", $statusVars) . "'", 0, 1);
} else {
$statusVarValues = array();
}
// Retrieve all required server variables
if (count($serverVars)) {
$serverVarValues = $GLOBALS['dbi']->fetchResult("SHOW GLOBAL VARIABLES WHERE Variable_name='" . implode("' OR Variable_name='", $serverVars) . "'", 0, 1);
} else {
$serverVarValues = array();
}
// ...and now assign them
foreach ($ret as $chart_id => $chartNodes) {
foreach ($chartNodes as $node_id => $nodeDataPoints) {
foreach ($nodeDataPoints as $point_id => $dataPoint) {
switch ($dataPoint['type']) {
case 'statusvar':
$ret[$chart_id][$node_id][$point_id]['value'] = $statusVarValues[$dataPoint['name']];
break;
case 'servervar':
$ret[$chart_id][$node_id][$point_id]['value'] = $serverVarValues[$dataPoint['name']];
break;
}
}
}
}
//.........这里部分代码省略.........