diff --git a/app/Actions/Server/StartSentinel.php b/app/Actions/Server/StartSentinel.php index eea429c79..342e72b1b 100644 --- a/app/Actions/Server/StartSentinel.php +++ b/app/Actions/Server/StartSentinel.php @@ -15,7 +15,7 @@ public function handle(Server $server, $version = 'latest', bool $restart = fals instant_remote_process(['docker rm -f coolify-sentinel'], $server, false); } instant_remote_process([ - "docker run --rm --pull always -d -e \"SCHEDULER=true\" --name coolify-sentinel -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify/metrics:/app/metrics -v /data/coolify/logs:/app/logs --pid host --health-cmd \"curl --fail http://127.0.0.1:8888/api/health || exit 1\" --health-interval 10s --health-retries 3 ghcr.io/coollabsio/sentinel:$version", + "docker run --rm --pull always -d -e \"SCHEDULER=true\" -e \"METRICS_HISTORY=10\" -e \"REFRESH_RATE=5\" --name coolify-sentinel -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify/metrics:/app/metrics -v /data/coolify/logs:/app/logs --pid host --health-cmd \"curl --fail http://127.0.0.1:8888/api/health || exit 1\" --health-interval 10s --health-retries 3 ghcr.io/coollabsio/sentinel:$version", 'chown -R 9999:root /data/coolify/metrics /data/coolify/logs', 'chmod -R 700 /data/coolify/metrics /data/coolify/logs', ], $server, false); diff --git a/app/Jobs/PullSentinelImageJob.php b/app/Jobs/PullSentinelImageJob.php index 1dd4b1dd3..c9a27e5f1 100644 --- a/app/Jobs/PullSentinelImageJob.php +++ b/app/Jobs/PullSentinelImageJob.php @@ -36,7 +36,10 @@ public function handle(): void { try { $version = get_latest_sentinel_version(); - if (! $version) { + if (isDev()) { + $version = "0.0.5"; + } + if (!$version) { ray('Failed to get latest Sentinel version'); return; @@ -52,7 +55,7 @@ public function handle(): void } ray('Sentinel image is up to date'); } catch (\Throwable $e) { - send_internal_notification('PullSentinelImageJob failed with: '.$e->getMessage()); + send_internal_notification('PullSentinelImageJob failed with: ' . $e->getMessage()); ray($e->getMessage()); throw $e; } diff --git a/app/Livewire/Charts/Server.php b/app/Livewire/Charts/Server.php new file mode 100644 index 000000000..8f8b5cf0e --- /dev/null +++ b/app/Livewire/Charts/Server.php @@ -0,0 +1,33 @@ +loadData(); + } + public function loadData() + { + $metrics = $this->server->getMetrics(); + $metrics = collect($metrics)->map(function ($metric) { + return [$metric[0], $metric[1]]; + }); + $this->dispatch("refreshChartData-{$this->chartId}", [ + 'seriesData' => $metrics, + ]); + } +} diff --git a/app/Models/Server.php b/app/Models/Server.php index b1419dc0e..915fc60ce 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -487,7 +487,6 @@ public function getMetrics() $parsedCollection = collect($cpu)->flatMap(function ($item) { return collect(explode("\n", trim($item)))->map(function ($line) { [$time, $value] = explode(',', trim($line)); - return [(int) $time, (float) $value]; }); })->toArray(); diff --git a/app/View/Components/ApexCharts.php b/app/View/Components/ApexCharts.php new file mode 100644 index 000000000..3f80a41a5 --- /dev/null +++ b/app/View/Components/ApexCharts.php @@ -0,0 +1,30 @@ +chartId = $chartId; + $this->seriesData = $seriesData; + $this->categories = $categories; + $this->seriesName = $seriesName ?? 'Series'; + } + + /** + * Get the view / contents that represent the component. + */ + public function render(): View|Closure|string + { + return view('components.apex-charts'); + } +} diff --git a/resources/views/components/apex-charts.blade.php b/resources/views/components/apex-charts.blade.php new file mode 100644 index 000000000..029e16df7 --- /dev/null +++ b/resources/views/components/apex-charts.blade.php @@ -0,0 +1,78 @@ +
+ + diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index c8d3a33cc..c1851e2f9 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -38,6 +38,7 @@ + @endauth @section('body') diff --git a/resources/views/livewire/charts/server.blade.php b/resources/views/livewire/charts/server.blade.php new file mode 100644 index 000000000..0047a6c12 --- /dev/null +++ b/resources/views/livewire/charts/server.blade.php @@ -0,0 +1,4 @@ +