本文整理汇总了PHP中PMA_getSysInfo函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getSysInfo函数的具体用法?PHP PMA_getSysInfo怎么用?PHP PMA_getSysInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_getSysInfo函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Parses and executes advisor rules
*
* @return array with run and parse results
*/
public function run()
{
// HowTo: A simple Advisory system in 3 easy steps.
// Step 1: Get some variables to evaluate on
$this->variables = array_merge($GLOBALS['dbi']->fetchResult('SHOW GLOBAL STATUS', 0, 1), $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES', 0, 1));
// Add total memory to variables as well
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
$memory = $sysinfo->memory();
$this->variables['system_memory'] = isset($memory['MemTotal']) ? $memory['MemTotal'] : 0;
// Step 2: Read and parse the list of rules
$this->parseResult = $this->parseRulesFile();
// Step 3: Feed the variables to the rules and let them fire. Sets
// $runResult
$this->runRules();
return array('parse' => array('errors' => $this->parseResult['errors']), 'run' => $this->runResult);
}
示例2: run
function run()
{
// HowTo: A simple Advisory system in 3 easy steps.
// Step 1: Get some variables to evaluate on
$this->variables = array_merge(PMA_DBI_fetch_result('SHOW GLOBAL STATUS', 0, 1), PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES', 0, 1));
if (PMA_DRIZZLE) {
$this->variables = array_merge($this->variables, PMA_DBI_fetch_result("SELECT concat('Com_', variable_name), variable_value\n FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1));
}
// Add total memory to variables as well
include_once 'libraries/sysinfo.lib.php';
$sysinfo = PMA_getSysInfo();
$memory = $sysinfo->memory();
$this->variables['system_memory'] = $memory['MemTotal'];
// Step 2: Read and parse the list of rules
$this->parseResult = $this->parseRulesFile();
// Step 3: Feed the variables to the rules and let them fire. Sets $runResult
$this->runRules();
return array('parse' => array('errors' => $this->parseResult['errors']), 'run' => $this->runResult);
}
示例3: 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);
}
示例4: PMA_getSysInfo
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)) {
示例5: testGetSysInfoSupported
/**
* Test for getting supported sysinfo object.
*
* @return void
*/
public function testGetSysInfoSupported()
{
$this->assertTrue(PMA_getSysInfo()->supported());
}
示例6: 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;
}
}
}
}
//.........这里部分代码省略.........