update
This commit is contained in:
parent
d7b1e4c00b
commit
bdd9aeec90
5 changed files with 55 additions and 9 deletions
|
@ -109,7 +109,7 @@ class ServerDiskUsageStatistic extends ApexChartWidget
|
|||
'stroke' => [
|
||||
'dashArray' => 10,
|
||||
],
|
||||
'labels' => ['Free Space'],
|
||||
'labels' => ['Used Space'],
|
||||
'colors' => ['#16a34a'],
|
||||
|
||||
];
|
||||
|
|
|
@ -18,7 +18,7 @@ class ServerMemoryStatistic extends ApexChartWidget
|
|||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected static ?string $heading = 'Memory Usage';
|
||||
protected static ?string $heading = 'RAM Usage';
|
||||
|
||||
protected static ?int $sort = 2;
|
||||
|
||||
|
@ -37,7 +37,7 @@ class ServerMemoryStatistic extends ApexChartWidget
|
|||
$serverStatistic = new \App\Statistics\ServerStatistic();
|
||||
$serverStats = $serverStatistic->getCurrentStats();
|
||||
|
||||
return view('charts.order-status.footer', ['data' => $serverStats]);
|
||||
return view('filament.widgets.server-memory-statistic', ['data' => $serverStats]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,9 +50,27 @@ class ServerMemoryStatistic extends ApexChartWidget
|
|||
$serverStatistic = new \App\Statistics\ServerStatistic();
|
||||
$serverStats = $serverStatistic->getCurrentStats();
|
||||
|
||||
$userPercentage = $serverStats['disk']['usedPercentage'];
|
||||
$userPercentage = str_replace('%', '', $userPercentage);
|
||||
$userPercentage = floatval($userPercentage);
|
||||
// try {
|
||||
// $memoryUsedPercentage = $serverStats['memory']['usedGb'] / $serverStats['memory']['totalGb'] * 100;
|
||||
// } catch (\Exception $e) {
|
||||
// $memoryUsedPercentage = 0;
|
||||
// }
|
||||
// $memoryUsedPercentage = round($memoryUsedPercentage, 0);
|
||||
|
||||
$memoryUsedPercentage = 0;
|
||||
$memoryFreePercentage = 0;
|
||||
|
||||
try {
|
||||
if ($serverStats['memory']['totalGb'] > 0) {
|
||||
$memoryUsedPercentage = $serverStats['memory']['usedGb'] / $serverStats['memory']['totalGb'] * 100;
|
||||
$memoryFreePercentage = 100 - $memoryUsedPercentage;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
$memoryUsedPercentage = round($memoryUsedPercentage, 0);
|
||||
$memoryFreePercentage = round($memoryFreePercentage, 0);
|
||||
|
||||
return [
|
||||
'chart' => [
|
||||
|
@ -62,7 +80,7 @@ class ServerMemoryStatistic extends ApexChartWidget
|
|||
'show' => false,
|
||||
],
|
||||
],
|
||||
'series' => [$userPercentage],
|
||||
'series' => [$memoryFreePercentage],
|
||||
'plotOptions' => [
|
||||
'radialBar' => [
|
||||
'startAngle' => 0,
|
||||
|
@ -109,7 +127,7 @@ class ServerMemoryStatistic extends ApexChartWidget
|
|||
'stroke' => [
|
||||
'dashArray' => 10,
|
||||
],
|
||||
'labels' => ['Free Space'],
|
||||
'labels' => ['Used RAM'],
|
||||
'colors' => ['#16a34a'],
|
||||
|
||||
];
|
||||
|
|
|
@ -82,7 +82,8 @@ class AdminPanelProvider extends PanelProvider
|
|||
// ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
->widgets([
|
||||
ServerDiskUsageStatistic::class,
|
||||
ServerMemoryStatisticCount::class,
|
||||
ServerMemoryStatistic::class,
|
||||
// ServerMemoryStatisticCount::class,
|
||||
CustomersCount::class,
|
||||
Websites::class,
|
||||
// Widgets\AccountWidget::class,
|
||||
|
|
|
@ -19,15 +19,19 @@ class ServerStatistic
|
|||
$freeMemoryExp = explode(' ', $freeMemoryExec);
|
||||
if (isset($freeMemoryExp[1])) {
|
||||
$memory['total'] = $this->getFormattedFileSize($freeMemoryExp[1] * 1024 * 1024, 2);
|
||||
$memory['totalGb'] = $freeMemoryExp[1] * 1024 * 1024;
|
||||
}
|
||||
if (isset($freeMemoryExp[2])) {
|
||||
$memory['used'] = $this->getFormattedFileSize($freeMemoryExp[2] * 1024 * 1024, 2);
|
||||
$memory['usedGb'] = $freeMemoryExp[2] * 1024 * 1024;
|
||||
}
|
||||
if (isset($freeMemoryExp[3])) {
|
||||
$memory['free'] = $this->getFormattedFileSize($freeMemoryExp[3] * 1024 * 1024, 2);
|
||||
$memory['freeGb'] = $freeMemoryExp[3] * 1024 * 1024;
|
||||
}
|
||||
if (isset($freeMemoryExp[4])) {
|
||||
$memory['shared'] = $this->getFormattedFileSize($freeMemoryExp[4] * 1024 * 1024, 2);
|
||||
$memory['sharedGb'] = $freeMemoryExp[4] * 1024 * 1024;
|
||||
}
|
||||
if (isset($freeMemoryExp[5])) {
|
||||
$memory['buffCache'] = $this->getFormattedFileSize($freeMemoryExp[5] * 1024 * 1024, 2);
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<div class="flex items-center justify-between mt-6 text-center">
|
||||
|
||||
<div>
|
||||
<h1>
|
||||
Total Memory
|
||||
</h1>
|
||||
<div class="text-3xl">{{ $data['memory']['total'] }}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h1>
|
||||
Used Memory
|
||||
</h1>
|
||||
<div class="text-3xl">{{ $data['memory']['used'] }}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h1>
|
||||
Free Memory
|
||||
</h1>
|
||||
<div class="text-3xl">{{ $data['memory']['free'] }}</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue