Skip to content

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.

Merge branch 'next' into main

Andras Bacsai1b135be3c571
diff --cc app/Models/Application.php
index 2a34caf7e4,8113f5ec9c..fdb8796ef1
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@@ -1168,14 -1168,32 +1168,41 @@@ class Application extends BaseMode
return $preview;
}
+ public static function getDomainsByUuid(string $uuid): array
+ {
+ $application = self::where('uuid', $uuid)->first();
+
+ if ($application) {
+ return $application->fqdns;
+ }
+
+ return [];
+ public function getMetrics(int $mins = 5)
+ {
+ $server = $this->destination->server;
+ $container_name = $this->uuid;
+ if ($server->isMetricsEnabled()) {
+ $from = now()->subMinutes($mins)->toIso8601ZuluString();
+ $metrics = instant_remote_process(["docker exec coolify-sentinel sh -c 'curl -H \"Authorization: Bearer {$server->settings->metrics_token}\" http://localhost:8888/api/container/{$container_name}/metrics/history?from=$from'"], $server, false);
+ if (str($metrics)->contains('error')) {
+ $error = json_decode($metrics, true);
+ $error = data_get($error, 'error', 'Something is not okay, are you okay?');
+ if ($error == 'Unauthorized') {
+ $error = 'Unauthorized, please check your metrics token or restart Sentinel to set a new token.';
+ }
+ throw new \Exception($error);
+ }
+ $metrics = str($metrics)->explode("\n")->skip(1)->all();
+ $parsedCollection = collect($metrics)->flatMap(function ($item) {
+ return collect(explode("\n", trim($item)))->map(function ($line) {
+ [$time, $cpu_usage_percent, $memory_usage, $memory_usage_percent] = explode(',', trim($line));
+ $cpu_usage_percent = number_format($cpu_usage_percent, 2);
+
+ return [(int) $time, (float) $cpu_usage_percent, (int) $memory_usage];
+ });
+ });
+
+ return $parsedCollection->toArray();
+ }
}
}