Line 95... |
Line 95... |
95 |
* @return void
|
95 |
* @return void
|
96 |
*/
|
96 |
*/
|
97 |
protected function cpuinfo()
|
97 |
protected function cpuinfo()
|
98 |
{
|
98 |
{
|
99 |
$dev = new CpuDevice();
|
99 |
$dev = new CpuDevice();
|
100 |
if (CommonFunctions::executeProgram('hostinfo', '| grep "Processor type"', $buf, PSI_DEBUG)) {
|
100 |
if (CommonFunctions::executeProgram('hostinfo', '', $buf, PSI_DEBUG) && ($buf !== '') && preg_match('/^Processor type:[ ]+(.+)$/m', $buf, $proc) && (($proc[1] = trim($proc[1])) !== '')) {
|
101 |
$dev->setModel(preg_replace('/Processor type: /', '', $buf));
|
101 |
$dev->setModel($proc[1]);
|
102 |
$buf=$this->grabkey('hw.model');
|
102 |
$buf=$this->grabkey('hw.model');
|
103 |
if (($buf !== null) && (trim($buf) != "")) {
|
103 |
if (($buf !== null) && (trim($buf) != "")) {
|
104 |
$this->sys->setMachine(trim($buf));
|
104 |
$this->sys->setMachine(trim($buf));
|
105 |
if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
|
105 |
if (CommonFunctions::rftsdata('ModelTranslation.txt', $buffer)) {
|
106 |
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
|
106 |
$buffer = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
|
Line 262... |
Line 262... |
262 |
*
|
262 |
*
|
263 |
* @return void
|
263 |
* @return void
|
264 |
*/
|
264 |
*/
|
265 |
protected function memory()
|
265 |
protected function memory()
|
266 |
{
|
266 |
{
|
267 |
$s = $this->grabkey('hw.memsize');
|
267 |
if (($s = $this->grabkey('hw.memsize')) > 0) {
|
- |
|
268 |
$this->sys->setMemTotal($s);
|
268 |
if (CommonFunctions::executeProgram('vm_stat', '', $pstat, PSI_DEBUG)) {
|
269 |
if (CommonFunctions::executeProgram('vm_stat', '', $pstat, PSI_DEBUG)) {
|
269 |
// calculate free memory from page sizes (each page = 4096)
|
270 |
// calculate free memory from page sizes (each page = 4096)
|
270 |
if (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf)) {
|
271 |
if (preg_match('/^Pages free:\s+(\S+)/m', $pstat, $free_buf)) {
|
271 |
if (preg_match('/^Anonymous pages:\s+(\S+)/m', $pstat, $anon_buf)
|
272 |
if (preg_match('/^Anonymous pages:\s+(\S+)/m', $pstat, $anon_buf)
|
272 |
&& preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)
|
273 |
&& preg_match('/^Pages wired down:\s+(\S+)/m', $pstat, $wire_buf)
|
Line 300... |
Line 301... |
300 |
} else {
|
301 |
} else {
|
301 |
$lines = preg_split("/\n/", $pstat, -1, PREG_SPLIT_NO_EMPTY);
|
302 |
$lines = preg_split("/\n/", $pstat, -1, PREG_SPLIT_NO_EMPTY);
|
302 |
$ar_buf = preg_split("/\s+/", $lines[1], 19);
|
303 |
$ar_buf = preg_split("/\s+/", $lines[1], 19);
|
303 |
$this->sys->setMemFree($ar_buf[2] * 4 * 1024);
|
304 |
$this->sys->setMemFree($ar_buf[2] * 4 * 1024);
|
304 |
}
|
305 |
}
|
305 |
|
- |
|
306 |
$this->sys->setMemTotal($s);
|
- |
|
307 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
306 |
$this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
|
- |
|
307 |
}
|
308 |
|
308 |
|
309 |
if (CommonFunctions::executeProgram('sysctl', 'vm.swapusage | colrm 1 22', $swapBuff, PSI_DEBUG)) {
|
309 |
if (($swap = $this->grabkey("vm.swapusage")) > 0) {
|
310 |
$swap1 = preg_split('/M/', $swapBuff);
|
310 |
$swap0 = preg_split('/M/', $swapBuff);
|
- |
|
311 |
$swap1 = preg_split('/=/', $swap0[0]);
|
311 |
$swap2 = preg_split('/=/', $swap1[1]);
|
312 |
$swap2 = preg_split('/=/', $swap0[1]);
|
312 |
$swap3 = preg_split('/=/', $swap1[2]);
|
313 |
$swap3 = preg_split('/=/', $swap0[2]);
|
313 |
if (($swap=trim($swap1[0])) > 0) {
|
314 |
if (($swap=str_replace(',', '.', trim($swap1[1]))) > 0) {
|
314 |
$dev = new DiskDevice();
|
315 |
$dev = new DiskDevice();
|
315 |
$dev->setName('SWAP');
|
316 |
$dev->setName('SWAP');
|
316 |
$dev->setMountPoint('SWAP');
|
317 |
$dev->setMountPoint('SWAP');
|
317 |
$dev->setFsType('swap');
|
318 |
$dev->setFsType('swap');
|
318 |
$dev->setTotal($swap * 1024 * 1024);
|
319 |
$dev->setTotal($swap * 1024 * 1024);
|
319 |
$dev->setUsed(trim($swap2[1]) * 1024 * 1024);
|
320 |
$dev->setUsed(str_replace(',', '.', trim($swap2[1])) * 1024 * 1024);
|
320 |
$dev->setFree(trim($swap3[1]) * 1024 * 1024);
|
321 |
$dev->setFree(str_replace(',', '.', trim($swap3[1])) * 1024 * 1024);
|
321 |
$this->sys->setSwapDevices($dev);
|
322 |
$this->sys->setSwapDevices($dev);
|
322 |
}
|
323 |
}
|
323 |
}
|
324 |
}
|
324 |
}
|
325 |
}
|
325 |
}
|
326 |
}
|
Line 415... |
Line 416... |
415 |
if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) {
|
416 |
if (isset($distro_arr['ProductName']) && isset($distro_arr['ProductVersion']) && isset($distro_arr['BuildVersion'])) {
|
416 |
$distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')';
|
417 |
$distro_arr['System Version'] = $distro_arr['ProductName'].' '.$distro_arr['ProductVersion'].' ('.$distro_arr['BuildVersion'].')';
|
417 |
}
|
418 |
}
|
418 |
if (isset($distro_arr['System Version'])) {
|
419 |
if (isset($distro_arr['System Version'])) {
|
419 |
$distro = $distro_arr['System Version'];
|
420 |
$distro = $distro_arr['System Version'];
|
420 |
if (preg_match('/^Mac OS|^OS X|^macOS/', $distro)) {
|
421 |
if (preg_match('/^Mac OS |^OS X |^macOS |^iPhone OS |^Mac OS$|^OS X$|^macOS$|^iPhone OS$/', $distro)) {
|
421 |
$this->sys->setDistributionIcon('Apple.png');
|
422 |
$this->sys->setDistributionIcon('Apple.png');
|
422 |
if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) ((\d+)\.\d+)/', $distro, $ver)
|
423 |
if (preg_match('/(^Mac OS X Server|^Mac OS X|^OS X Server|^OS X|^macOS Server|^macOS) ((\d+)\.\d+)/', $distro, $ver)
|
423 |
&& ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
|
424 |
&& ($list = @parse_ini_file(PSI_APP_ROOT."/data/osnames.ini", true))) {
|
424 |
if (isset($list['macOS'][$ver[2]])) {
|
425 |
if (isset($list['macOS'][$ver[2]])) {
|
425 |
$distro.=' '.$list['macOS'][$ver[2]];
|
426 |
$distro.=' '.$list['macOS'][$ver[2]];
|