/** * filesystem information * * @return void */ protected function filesystems() { $arrResult = Parser::df(); foreach ($arrResult as $dev) { $this->sys->setDiskDevices($dev); } }
/** * filesystem information * * @return void */ private function _filesystems() { $df_args = ""; $hideFstypes = array(); if (defined('PSI_HIDE_FS_TYPES') && is_string(PSI_HIDE_FS_TYPES)) { if (preg_match(ARRAY_EXP, PSI_HIDE_FS_TYPES)) { $hideFstypes = eval(PSI_HIDE_FS_TYPES); } else { $hideFstypes = array(PSI_HIDE_FS_TYPES); } } foreach ($hideFstypes as $Fstype) { $df_args .= "-x {$Fstype} "; } if ($df_args !== "") { $df_args = trim($df_args); //trim spaces $arrResult = Parser::df("-P {$df_args} 2>/dev/null"); } else { $arrResult = Parser::df("-P 2>/dev/null"); } foreach ($arrResult as $dev) { $this->sys->setDiskDevices($dev); } }
/** * filesystem information * * @return void */ private function _filesystems() { $arrResult = Parser::df("-P"); foreach ($arrResult as $dev) { $this->sys->setDiskDevices($dev); } }
/** * filesystem information * * @return void */ private function _filesystems() { $notwas = true; if (CommonFunctions::executeProgram('df', '2>/dev/null ', $df, PSI_DEBUG) && preg_match("/\\s+[0-9\\.]+[KMGT]\\s+/", $df)) { $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY); if (CommonFunctions::executeProgram('mount', '', $mount, PSI_DEBUG)) { $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY); foreach ($mount as $mount_line) { $mount_buf = preg_split('/\\s+/', $mount_line); if (count($mount_buf) == 6) { $mount_parm[$mount_buf[1]]['fstype'] = $mount_buf[2]; if (PSI_SHOW_MOUNT_OPTION) { $mount_parm[$mount_buf[1]]['options'] = $mount_buf[3]; } $mount_parm[$mount_buf[1]]['mountdev'] = $mount_buf[0]; } } foreach ($df as $df_line) { if ((preg_match("/^(\\/\\S+)(\\s+)(([0-9\\.]+)([KMGT])(\\s+)([0-9\\.]+)([KMGT])(\\s+)([0-9\\.]+)([KMGT])(\\s+))/", $df_line, $df_buf) || preg_match("/^(\\/[^\\s\\:]+)\\:(\\s+)(([0-9\\.]+)([KMGT])(\\s+total\\,\\s+)([0-9\\.]+)([KMGT])(\\s+used\\,\\s+)([0-9\\.]+)([KMGT])(\\s+available))/", $df_line, $df_buf)) && !preg_match('/^\\/mnt\\/asec\\/com\\./', $df_buf[1])) { $dev = new DiskDevice(); if (PSI_SHOW_MOUNT_POINT) { $dev->setMountPoint($df_buf[1]); } if ($df_buf[5] == 'K') { $dev->setTotal($df_buf[4] * 1024); } elseif ($df_buf[5] == 'M') { $dev->setTotal($df_buf[4] * 1024 * 1024); } elseif ($df_buf[5] == 'G') { $dev->setTotal($df_buf[4] * 1024 * 1024 * 1024); } elseif ($df_buf[5] == 'T') { $dev->setTotal($df_buf[4] * 1024 * 1024 * 1024 * 1024); } if ($df_buf[8] == 'K') { $dev->setUsed($df_buf[7] * 1024); } elseif ($df_buf[8] == 'M') { $dev->setUsed($df_buf[7] * 1024 * 1024); } elseif ($df_buf[8] == 'G') { $dev->setUsed($df_buf[7] * 1024 * 1024 * 1024); } elseif ($df_buf[8] == 'T') { $dev->setUsed($df_buf[7] * 1024 * 1024 * 1024 * 1024); } if ($df_buf[11] == 'K') { $dev->setFree($df_buf[10] * 1024); } elseif ($df_buf[11] == 'M') { $dev->setFree($df_buf[10] * 1024 * 1024); } elseif ($df_buf[11] == 'G') { $dev->setFree($df_buf[10] * 1024 * 1024 * 1024); } elseif ($df_buf[11] == 'T') { $dev->setFree($df_buf[10] * 1024 * 1024 * 1024 * 1024); } if (isset($mount_parm[$df_buf[1]])) { $dev->setFsType($mount_parm[$df_buf[1]]['fstype']); $dev->setName($mount_parm[$df_buf[1]]['mountdev']); if (PSI_SHOW_MOUNT_OPTION) { if (PSI_SHOW_MOUNT_CREDENTIALS) { $dev->setOptions($mount_parm[$df_buf[1]]['options']); } else { $mpo = $mount_parm[$df_buf[1]]['options']; $mpo = preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo); $mpo = preg_replace('/,guest,/i', ',', $mpo); $mpo = preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo); $mpo = preg_replace('/,user=[^,]*,/i', ',', $mpo); $mpo = preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo); $mpo = preg_replace('/,username=[^,]*,/i', ',', $mpo); $mpo = preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo); $mpo = preg_replace('/,password=[^,]*,/i', ',', $mpo); $dev->setOptions($mpo); } } } $this->sys->setDiskDevices($dev); $notwas = false; } } } } if ($notwas) { // try Linux df style $arrResult = Parser::df("-P 2>/dev/null", false); foreach ($arrResult as $dev) { $this->sys->setDiskDevices($dev); } } }