系统信息查询(常规版本)

*这个新方法只会获取部分数据,节省系统资源
This commit is contained in:
Chenx221 2024-04-15 16:09:37 +08:00
parent 2f8999cb3d
commit 2a20dea8cf
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021

View File

@ -6,7 +6,6 @@ use app\models\CollectionTasks;
use app\models\Share; use app\models\Share;
use app\models\User; use app\models\User;
use COM; use COM;
use DateInterval;
use DateTime; use DateTime;
use Yii; use Yii;
use yii\db\Exception; use yii\db\Exception;
@ -585,13 +584,27 @@ class SystemInfoHelper
/** /**
* 获取系统信息(刷新) * 获取系统信息(刷新)
* 为了减少资源消耗,只刷新部分数据 * 为了减少资源消耗,只获取部分数据
* @return SystemInfoHelper * @return SystemInfoHelper
*/ */
public static function getSysInfoFre(): SystemInfoHelper public static function getSysInfoFre(): SystemInfoHelper
{ {
$sysInfo = new SystemInfoHelper(); $sysInfo = new SystemInfoHelper();
// TODO: Implement getSysInfoFre() method. $sysInfo->detectOsType();
if ($sysInfo->osType === 1) {
$sysInfo->detectLoad();
} else {
$sysInfo->wmi = new COM('winmgmts://');
$sysInfo->load = -1;
}
$sysInfo->detectCpu();
$sysInfo->detectServerTime();
$sysInfo->detectServerUptime();
$sysInfo->detectCpuUsage();
$sysInfo->detectRamUsage();
$sysInfo->detectDataMountPoint();
return $sysInfo; return $sysInfo;
} }