An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Refactor metrics retrieval and update chart visualization
Andras Bacsai1f5f51e3e545
diff --git a/app/Models/Server.php b/app/Models/Server.phpindex a4f23aa2f4..2f4c290809 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -483,14 +483,12 @@ $schema://$host {public function getMetrics(){if ($this->is_metrics_enabled) {- $cpu = instant_remote_process(["cat /data/coolify/metrics/cpu.csv | grep 'Overall' | tail -200 | awk -F, '{print $1\",\" \$NF}'"], $this, false);- $cpu = str($cpu)->replace("%", "");- ray($cpu);+ $from = now()->subMinutes(5)->toIso8601ZuluString();+ $cpu = instant_remote_process(["docker exec coolify-sentinel sh -c 'curl http://localhost:8888/api/cpu/history?from=$from'"], $this, false);+ $cpu = str($cpu)->explode("\n")->skip(1)->all();$parsedCollection = collect($cpu)->flatMap(function ($item) {return collect(explode("\n", trim($item)))->map(function ($line) {list($time, $value) = explode(',', trim($line));- // convert $time from nanoseconds to milliseconds for apexcharts- $time = (int) $time / 1000000;return [(int) $time, (float) $value];});})->toArray();diff --git a/resources/views/livewire/project/shared/logs.blade.php b/resources/views/livewire/project/shared/logs.blade.phpindex 4831b91e45..a48b076348 100644--- a/resources/views/livewire/project/shared/logs.blade.php+++ b/resources/views/livewire/project/shared/logs.blade.php@@ -93,6 +93,7 @@return '#D9534F'}}],+xaxis: {type: 'datetime'},@@ -107,9 +108,12 @@enabled: true},chart: {+ stroke: {+ curve: 'smooth',+ },height: 500,width: "100%",- type: "area",+ type: "line",toolbar: {show: true},