|
@@ -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'],
|
|
|
|
|
|
];
|