系统信息显示(2/3)

*还有很多改进空间
This commit is contained in:
Chenx221 2024-04-12 16:15:43 +08:00
parent c231a49df7
commit f8936cd49b
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 56 additions and 74 deletions

View File

@ -14,7 +14,7 @@ use app\models\User;
use app\models\UserSearch; use app\models\UserSearch;
use app\utils\AdminSword; use app\utils\AdminSword;
use app\utils\FileSizeHelper; use app\utils\FileSizeHelper;
use DateTime; use app\utils\SystemInfoHelper;
use OTPHP\TOTP; use OTPHP\TOTP;
use RuntimeException; use RuntimeException;
use Throwable; use Throwable;
@ -586,40 +586,18 @@ class AdminController extends Controller
*/ */
public function actionSysinfo(): string public function actionSysinfo(): string
{ {
return $this->render('sysinfo'); $fullInfo = SystemInfoHelper::getSysInfoInit();
return $this->render('sysinfo', [
'systemInfo' => $fullInfo,
]);
} }
/** /**
* Get server status * Get server status
* 只兼容Windows和Linux
* other不考虑
* @return void * @return void
*/ */
public function actionGetServerStatus(): void public function actionGetServerStatus(): void
{ {
//需要收集的信息
//hostname
//os
//cpu
//memory
//server time
//server uptime
//is windows?
//server load
//server cpu usage
//server memory usage
//storage data drive
//file system
//drive size
//drive used & free
//dns server
//gateway
//network interface(status,speed,ipv4v6 address)
//All users number
//active users number(24h)
//share number,collection number
//php version,memory limit,max execution time,max upload size,max post size,extension
//database type,version,size
//迁移到SystemInfoHelper Util
} }
} }

View File

@ -1,7 +1,10 @@
<?php <?php
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $systemInfo SystemInfoHelper */
use app\assets\FontAwesomeAsset; use app\assets\FontAwesomeAsset;
use app\utils\SystemInfoHelper;
use yii\bootstrap5\Html; use yii\bootstrap5\Html;
FontAwesomeAsset::register($this); FontAwesomeAsset::register($this);
@ -16,31 +19,32 @@ $this->title = '系统信息';
<div> <div>
<h2> <h2>
<i class="fa-solid fa-server"></i> <i class="fa-solid fa-server"></i>
<!--hostname--> <?= $systemInfo->hostname ?>
</h2> </h2>
<p> <p>
OS: OS:
<strong><!--Server Operate System--></strong> <strong><?= $systemInfo->os ?></strong>
</p> </p>
<p> <p>
CPU: CPU:
<strong><!--CPU--></strong> <strong><?= $systemInfo->cpu ?></strong>
</p> </p>
<p> <p>
RAM: RAM:
<strong><!--RAM--></strong> <strong><?= $systemInfo->ram ?></strong>
</p> </p>
<p> <p>
Server Time: Server Time:
<strong><!--Server Time--></strong> <strong><?= $systemInfo->serverTime ?></strong>
</p> </p>
<p> <p>
Server Up Time: Server Up Time:
<strong><!--Server Up Time--></strong> <strong><?= $systemInfo->serverUpTime ?></strong>
</p> </p>
</div> </div>
<hr> <hr>
<div> <div>
<?php if ($systemInfo->osType === 2): ?>
<div> <div>
<h2> <h2>
<i class="fa-solid fa-bars-progress"></i> <i class="fa-solid fa-bars-progress"></i>
@ -48,9 +52,10 @@ $this->title = '系统信息';
</h2> </h2>
<!-- Load Graph --> <!-- Load Graph -->
<p> <p>
<!-- Load value --> Load Average: <?= $systemInfo->load ?> (Last 1 min)
</p> </p>
</div> </div>
<?php endif; ?>
<div> <div>
<h2> <h2>
<i class="fa-solid fa-microchip"></i> <i class="fa-solid fa-microchip"></i>
@ -58,15 +63,15 @@ $this->title = '系统信息';
</h2> </h2>
<!-- CPU Graph --> <!-- CPU Graph -->
<p> <p>
<!-- CPU value --> CPU Usage: <?= $systemInfo->cpuUsage ?>%
</p> </p>
</div> </div>
<div> <div>
<h2> <h2>
<i class="fa-solid fa-memory"></i> <i class="fa-solid fa-memory"></i>
RAM Memory
</h2> </h2>
<!-- RAM Graph --> <!-- Memory Graph -->
<p> <p>
<!-- RAM value --> <!-- RAM value -->
</p> </p>
@ -90,19 +95,19 @@ $this->title = '系统信息';
<div> <div>
<h3>Data</h3> <h3>Data</h3>
Mount: Mount:
<span><!-- Mount point | Drive letter--></span> <span><?= $systemInfo->dataMountPoint ?></span>
<br> <br>
File System: File System:
<span><!-- File System--></span> <span><?= $systemInfo->mp_fs ?></span>
<br> <br>
Size: Size:
<span><!-- Size--></span> <span><?= $systemInfo->mp_size ?></span>
<br> <br>
Free: Free:
<span><!-- Free--></span> <span><?= $systemInfo->mp_avail ?></span>
<br> <br>
Used: Used:
<span><!-- Used--></span> <span><?= $systemInfo->mp_used ?></span>
</div> </div>
</div> </div>
</div> </div>
@ -114,32 +119,31 @@ $this->title = '系统信息';
</h2> </h2>
<p> <p>
Hostname: Hostname:
<!-- Hostname --> <?= $systemInfo->hostname ?>
</p> </p>
<p> <p>
DNS: DNS:
<!-- DNS --> <?= $systemInfo->dns ?>
</p> </p>
<p> <p>
Gateway: Gateway:
<!-- Gateway --> <?= $systemInfo->gateway ?>
</p> </p>
<div> <div>
<!-- 数量基于实际情况 -->
<div> <div>
<div> <div>
<h3><!--Interface Name--></h3> <h3><?= $systemInfo->nic['interfaceName'] ?></h3>
Status: Status:
<span><!--Status--></span> <span><?= $systemInfo->nic['mac'] ?></span>
<br> <br>
Speed: Speed:
<span><!--Speed--></span> <span><?= $systemInfo->nic['speed'] ?></span>
<br> <br>
IPv4: IPv4:
<span><!--IPv4--></span> <span><?= $systemInfo->nic['ipv4'] ?></span>
<br> <br>
IPv6: IPv6:
<span><!--IPv6--></span> <span><?= $systemInfo->nic['ipv6'] ?></span>
</div> </div>
</div> </div>
</div> </div>
@ -152,10 +156,10 @@ $this->title = '系统信息';
</h2> </h2>
<div> <div>
All: All:
<span><!-- All Users--></span> <span><?= $systemInfo->users ?></span>
<br> <br>
Active (within 24h): Active (within 24h):
<span><!-- Active Users--></span> <span><?= $systemInfo->activeUsers ?></span>
</div> </div>
</div> </div>
<hr> <hr>
@ -167,7 +171,7 @@ $this->title = '系统信息';
</h2> </h2>
<div> <div>
Link: Link:
<span><!-- The Number of Share Link--></span> <span><?= $systemInfo->shares ?></span>
</div> </div>
</div> </div>
<div> <div>
@ -177,7 +181,7 @@ $this->title = '系统信息';
</h2> </h2>
<div> <div>
Collection: Collection:
<span><!-- The Number of Collection Link--></span> <span><?= $systemInfo->collections ?></span>
</div> </div>
</div> </div>
</div> </div>
@ -190,22 +194,22 @@ $this->title = '系统信息';
</h2> </h2>
<div> <div>
Version: Version:
<span><!-- PHP Version--></span> <span><?= $systemInfo->phpVersion ?></span>
<br> <br>
Memory Limit: Memory Limit:
<span><!-- Memory Limit--></span> <span><?= $systemInfo->memoryLimit ?></span>
<br> <br>
Max Execution Time: Max Execution Time:
<span><!-- Max Execution Time--></span> <span><?= $systemInfo->maxExecutionTime ?></span>
<br> <br>
Upload Max Filesize: Upload Max Filesize:
<span><!-- Upload Max Filesize--></span> <span><?= $systemInfo->uploadMaxFilesize ?></span>
<br> <br>
Post Max Size: Post Max Size:
<span><!-- Post Max Size--></span> <span><?= $systemInfo->postMaxSize ?></span>
<br> <br>
Extension: Extension:
<span><!-- Extension--></span> <span><?= $systemInfo->extensions ?></span>
</div> </div>
</div> </div>
<div> <div>
@ -215,13 +219,13 @@ $this->title = '系统信息';
</h2> </h2>
<div> <div>
Type: Type:
<span><!-- Database Type--></span> <span><?= $systemInfo->dbType ?></span>
<br> <br>
Version: Version:
<span><!-- Database Version--></span> <span><?= $systemInfo->dbVersion ?></span>
<br> <br>
Size: Size:
<span><!-- Database Size--></span> <span><?= $systemInfo->dbSize ?></span>
</div> </div>
</div> </div>
</div> </div>