2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Hold PMA\libraries\SysInfoWINNT class
8 namespace PMA\libraries
;
13 * Windows NT based SysInfo class
15 * @package PhpMyAdmin-sysinfo
17 class SysInfoWINNT
extends \PMA\libraries\SysInfo
23 * Constructor to access to wmi database.
25 public function __construct()
27 if (!class_exists('COM')) {
30 // initialize the wmi object
31 $objLocator = new COM('WbemScripting.SWbemLocator');
32 $this->_wmi
= $objLocator->ConnectServer();
37 * Gets load information
39 * @return array with load data
45 $buffer = $this->_getWMI('Win32_Processor', array('LoadPercentage'));
47 foreach ($buffer as $load) {
48 $value = $load['LoadPercentage'];
49 $loadavg .= $value . ' ';
53 return array('loadavg' => $sum / count($buffer));
57 * Checks whether class is supported in this environment
59 * @return true on success
61 public function supported()
63 return !is_null($this->_wmi
);
69 * @param string $strClass Class to read
70 * @param array $strValue Values to read
72 * @return array with results
74 private function _getWMI($strClass, $strValue = array())
78 $objWEBM = $this->_wmi
->Get($strClass);
79 $arrProp = $objWEBM->Properties_
;
80 $arrWEBMCol = $objWEBM->Instances_();
81 foreach ($arrWEBMCol as $objItem) {
82 $arrInstance = array();
83 foreach ($arrProp as $propItem) {
84 $name = $propItem->Name
;
85 if (empty($strValue) ||
in_array($name, $strValue)) {
86 $value = $objItem->$name;
87 $arrInstance[$name] = trim($value);
90 $arrData[] = $arrInstance;
97 * Gets information about memory usage
99 * @return array with memory usage data
103 $buffer = $this->_getWMI(
104 "Win32_OperatingSystem",
105 array('TotalVisibleMemorySize', 'FreePhysicalMemory')
108 $mem['MemTotal'] = $buffer[0]['TotalVisibleMemorySize'];
109 $mem['MemFree'] = $buffer[0]['FreePhysicalMemory'];
110 $mem['MemUsed'] = $mem['MemTotal'] - $mem['MemFree'];
112 $buffer = $this->_getWMI('Win32_PageFileUsage');
114 $mem['SwapTotal'] = 0;
115 $mem['SwapUsed'] = 0;
116 $mem['SwapPeak'] = 0;
118 foreach ($buffer as $swapdevice) {
119 $mem['SwapTotal'] +
= $swapdevice['AllocatedBaseSize'] * 1024;
120 $mem['SwapUsed'] +
= $swapdevice['CurrentUsage'] * 1024;
121 $mem['SwapPeak'] +
= $swapdevice['PeakUsage'] * 1024;